1. 程式人生 > >如何判斷一個list中是否存在重複值

如何判斷一個list中是否存在重複值

方法一:

 bool b= lst.GroupBy(l=>l.Name).Where(g=>g.Count()>1).Count()>0;

方法二:

lst.ToDictionary(o => { return o.name; });
不出異常就沒重複

http://bbs.csdn.net/topics/390492533