运用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));

 

posted @ 2013-07-25 14:00  cnkker.com  阅读(447)  评论(1编辑  收藏  举报