using System.Collections.Generic;
public static void Main()
GetWordsFrequencyCount("My bike and my book");
GetWordsLenthFrequencyCount("My bike and my book");
private static void GetWordsLenthFrequencyCount(string sentence)
var dictionary = new Dictionary<int, int>();
string[] words = sentence.ToLower().Split(' ');
foreach (var word in words)
if (!dictionary.ContainsKey(word.Length))
dictionary.Add(word.Length, 1);
dictionary[word.Length]++;
foreach (var key in dictionary.Keys)
Console.WriteLine(key + ": " + dictionary[key]);
private static void GetWordsFrequencyCount(string sentence)
var dictionary = new Dictionary<string, int>();
string[] words = sentence.ToLower().Split(' ');
foreach (var word in words)
if (!dictionary.ContainsKey(word))
foreach (var key in dictionary.Keys)
Console.WriteLine(key + ": " + dictionary[key]);