如果我有一个列表
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);
