Skip to main content
 首页 » 编程设计

c#之如何找到数字列表中的总冗余

2024年02月05日11Renyi-Fan

如果我有一个列表

List<int> mylist = new List<int>(); 
mylist.Add(15); 
mylist.Add(15); 
mylist.Add(10); 
mylist.Add(10); 
mylist.Add(10); 

如果你想要 Count() 等于“10” 给我数字 3

请您参考如下方法:

听起来您可能只想使用 LINQ:

int target = 10; // Or whatever 
int count = myList.Count(x => x == target);