c# List获取重复项

2021-05-03 18:28

阅读:607

标签:class   code   lin   div   reac   span   for   飞机   c#   

 1 List t = new List() { 
 2                 new Test(){id=1,name="车辆"},
 3                 new Test(){id=2,name="车辆"},
 4                 new Test(){id=3,name="飞机"},
 5                 new Test(){id=4,name="火车"},
 6                 new Test(){id=4,name="火车"},
 7             };
 8          //同名
 9             var q = t.GroupBy(x => x.name).Where(x => x.Count() > 1).ToList();
10  
11             foreach (var item in q)
12             {
13                 Console.WriteLine(item.Key);
14             }

sql:

1 --重复的物品编码
2 SELECT COUNT(0) AS num,Code
3 FROM dbo.Goods 
4 GROUP BY Code
5 HAVING COUNT(0)>1
6 ORDER BY Code

 

c# List获取重复项

标签:class   code   lin   div   reac   span   for   飞机   c#   

原文地址:http://www.cnblogs.com/nlh774/p/7741891.html


评论


亲,登录后才可以留言!