C# 14 · Collections and LINQ

Group items

Group by a key and compute a value for each group.

var byCountry = users.GroupBy(u => u.Country)
                     .Select(g => new { Country = g.Key, Count = g.Count() });

Official C# 14 documentation

More collections and linq commands

All collections and linq commands · C# 14 cheatsheet

Was this page helpful?