统计数组中每个元素出现的次数

   Dictionary<string, int> counter = new Dictionary<string, int>();
            foreach (string c in  数组)
            {
                if (counter.ContainsKey(c))
                {
                    counter[c]++;
                }
                else
                {
                    counter.Add(c, 1);
                }
                if (counter[max] < counter[c])
                    max = c;
            }

max为元素    counter[max]出现次数最多的元素出现的次数
原文地址:https://www.cnblogs.com/shenwuyu/p/5163787.html