Skip to content
Justice Tech School

LINQ GroupBy, Join and Aggregates

GroupBy buckets items, Sum, Average, Min and Max aggregate.

Example
var words = new[] { "apple", "avocado", "banana", "blueberry", "cherry" };
foreach (var g in words.GroupBy(w => w[0]))
    Console.WriteLine($"{g.Key}: {string.Join(",", g)}");
Console.WriteLine(words.Average(w => w.Length));

Exercise

Group.

words.(w => w[0])

Quiz Test

What does Average return?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.