运用linq查找所有重复的元素
如题:
有一个List<string>类型的List<T>
List<String> list = new List<String>{"6","1","2","4","6","5","1"};`
需要返回结果List包含 {"6","1"}
代码如下:
var duplicates = lst.GroupBy(s => s) .SelectMany(grp => grp.Skip(1));
如题:
有一个List<string>类型的List<T>
List<String> list = new List<String>{"6","1","2","4","6","5","1"};`
需要返回结果List包含 {"6","1"}
代码如下:
var duplicates = lst.GroupBy(s => s) .SelectMany(grp => grp.Skip(1));