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() });
C# 14 · Collections and LINQ
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() });
Was this page helpful?