c#判断list链表是否有重复内容
作者:互联网
List<string> vList = new List<string>();
vList.Add("aa");
vList.Add("aa");
vList.Add("bb");
vList.Add("bb");
// vList.Add("bb");
//int HaveDuplicates = vList.Where(g => g.Equals("aa")).Count();
bool HaveDuplicates = vList.GroupBy(i => i).Where(g => g.Count() > 1).Count() >= 1;
//int HaveDuplicates = vList.GroupBy(i => i).Where(g => g.Count() > 1).Count();//显示2
//foreach(var aa in HaveDuplicates)
{
// Console.WriteLine(aa.ToString());
// MessageBox.Show(aa);
//MessageBox.Show(aa.ToString());
}
c#判断list链表是否有重复内容
lambda表达式+linq语句
标签:aa,Count,bb,c#,list,链表,Add,HaveDuplicates,vList 来源: https://blog.csdn.net/txwtech/article/details/122198440