Lambda expression to find difference
问题 With the following data string[] data = { "a", "a", "b" }; I'd very much like to find duplicates and get this result: a I tried the following code var a = data.Distinct().ToList(); var b = a.Except(a).ToList(); obviously this didn't work, I can see what is happening above but I'm not sure how to fix it. 回答1: When runtime is no problem, you could use var duplicates = data.Where(s => data.Count(t => t == s) > 1).Distinct().ToList(); Good old O(n^n) =) Edit: Now for a better solution. =) If you