using System.Collections.Generic;
public static void Main()
string fileName = "test.txt";
string[] words = System.IO.File.ReadAllText(fileName).Split();
Dictionary<string, int> map = new Dictionary<string, int>();
foreach (string word in words)
if (map.ContainsKey(word))
List<KeyValuePair<string, int> > list = new List<KeyValuePair<string, int> >();
list.Sort((x,y) => y.Value.CompareTo(x.Value));
Console.WriteLine(i.Key);