linq check duplicates code example
Example 1: c# linq check for duplicate
var duplicates = list.GroupBy(x => x.Key).Any(g => g.Count() > 1);
Example 2: c# find duplicates in list
var query = lst.GroupBy(x => x)
.Where(g => g.Count() > 1)
.Select(y => y.Key)
.ToList();