public static void Main ()
Console.WriteLine("Enter words. Counts the frequency of words.");
var Answer1 = Console.ReadLine();
GetWordsFrequencyCount(Answer1);
Console.WriteLine("Enter words. Counts the frequency of words with the same length.");
var Answer2 = Console.ReadLine();
GetWordsLenthFrequencyCount(Answer2);
public static void GetWordsFrequencyCount(string str)
var result = str.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries)
.GroupBy(r => r, StringComparer.InvariantCultureIgnoreCase)
foreach (var item in result)
Console.WriteLine("{0} : {1}", item.Word, item.Count);
public static void GetWordsLenthFrequencyCount(string str)
var result = str.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries)
foreach (var item in result)
Console.WriteLine("Length of word: {0} , Count: {1}", item.Length, item.Count);