Try to use GroupBy
and Any
like;
lstNames.GroupBy(n => n).Any(c => c.Count() > 1);
GroupBy
method;
Groups the elements of a sequence according to a specified key
selector function and projects the elements for each group by using a
specified function.
Any
method, it returns boolean
;
Determines whether any element of a sequence exists or satisfies a
condition.