I have a List<string>
which has some words duplicated. I need to find all words which are duplicates.
Any trick to get them all?
I have a List<string>
which has some words duplicated. I need to find all words which are duplicates.
Any trick to get them all?
For what it's worth, here is my way:
In .NET framework 3.5 and above you can use
Enumerable.GroupBy
which returns an enumerable of enumerables of duplicate keys, and then filter out any of the enumerables that have a Count of <=1, then select their keys to get back down to a single enumerable: