using System.Collections.Generic;
public static void Main()
string[] values = { "bird", "cat", "bird", "dog", "bird", "man", "frog", "cat" };
MaxOccurrenceOfWord(values);
public static int MaxOccurrenceOfWord(string[] words)
var counts = new Dictionary<string, int>();
foreach (var word in words)
counts.TryGetValue(word, out count);
Console.WriteLine("{0} {1}",word, count);
string mostCommonWord = null;
foreach (var pair in counts)
if (pair.Value > occurrences)
occurrences = pair.Value;
mostCommonWord = pair.Key;
Console.WriteLine("The most common number is {0} and it appears {1} times",
mostCommonWord, occurrences);