标签:
int[] list = new int[] { 1,1,2,3,1,2,4,3,3,2,4,5,6,5,6,7,3,2,8}; Dictionary<int, int> dic = new Dictionary<int, int>(); foreach (int item in list) { if (!dic.ContainsKey(item)) { dic[item] = 1; } else { dic[item]++; } } foreach (var item in dic) { Console.WriteLine(item.Key+":有{0}个",item.Value); } Console.ReadKey();
标签:
原文地址:http://www.cnblogs.com/527289276qq/p/4441084.html