Mid From PDF LINQ LINQ

How to group by multiple keys?

How to group by multiple keys?

var groupedMulti = employees

.GroupBy(e => new { e.Department, SalaryLevel = e.Salary > 75000

? "High" : "Low" });

foreach (var group in groupedMulti)

Console.WriteLine($"{group.Key.Department} -

{group.Key.SalaryLevel} ({group.Count()} employees)");

More from LINQ Tutorial

All questions for this course
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details