score:2

Accepted answer

You can try to GroupBy the Country, SwiftCode

swiftCodeInfo.GroupBy(l => new { l.Country, l.SwiftCode })
             .Select(g => new BranchCode {
                    Country = g.Key.Country, 
                    SwiftCode = g.Key.SwiftCode, 
                    BranchCodes = g.Select(i => i.BranchCode).ToList() 
                });

c# online


Related Articles