Sherzy
1/31/2019 - 5:25 PM

Find duplicates in List with linq

 var duplicates = judges
    .GroupBy(x => x.LastName)      // group matching items
    .Where(g => g.Skip(1).Any())   // where the group contains more than one item
    .SelectMany(g => g);           // re-expand the groups with more than one item

// or if you want a distinct list
//var duplicates = judges.GroupBy(s => s.LastName)
//    .SelectMany(grp => grp.Skip(1));

judges = duplicates.ToList();