Mid LINQ

How to use LINQ to find employees with duplicate names?

How to use LINQ to find employees with duplicate names?

var duplicates = employees

.GroupBy(e => e.Name)

.Where(g => g.Count() > 1)

.Select(g => g.Key);

foreach (var name in duplicates)

Console.WriteLine(name);

More from LINQ Tutorial

All questions for this course