how to determine if a string is a duplicate in list c# code example
Example 1: c# find duplicates in list
var query = lst.GroupBy(x => x)
.Where(g => g.Count() > 1)
.Select(y => y.Key)
.ToList();
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
}