check duplicate list c# code example
Example 1: c# linq check for duplicate
var duplicates = list.GroupBy(x => x.Key).Any(g => g.Count() > 1);
Example 2: c# see if list contains any duplicates
var list = new List<string>();
// Fill the list
if(list.Count != list.Distinct().Count())
{
// Duplicates exist
}