using System.Collections.Generic;
public static void Main(string[] args)
var text = "My bike and my book";
var wordsFrequencyCount = GetWordsFrequencyCount(text);
foreach (var kvp in wordsFrequencyCount)
Console.WriteLine($"{kvp.Key}: {kvp.Value}");
var wordsLengthFrequencyCount = GetWordsLengthFrequencyCount(text);
foreach (var kvp in wordsLengthFrequencyCount)
Console.WriteLine($"{kvp.Key}: {kvp.Value}");
public static Dictionary<string, int> GetWordsFrequencyCount(string text)
var wordsFrequencyCount = new Dictionary<string, int>();
return wordsFrequencyCount;
var words = text.Trim().ToLower().Split(" ");
foreach (var word in words)
if (wordsFrequencyCount.ContainsKey(key))
wordsFrequencyCount[key] += 1;
wordsFrequencyCount[key] = 1;
return wordsFrequencyCount;
public static Dictionary<int, int> GetWordsLengthFrequencyCount(string text)
var wordsLengthFrequencyCount = new Dictionary<int, int>();
return wordsLengthFrequencyCount;
var words = text.Trim().ToLower().Split(" ");
foreach (var word in words)
if (wordsLengthFrequencyCount.ContainsKey(key))
wordsLengthFrequencyCount[key] += 1;
wordsLengthFrequencyCount[key] = 1;
return wordsLengthFrequencyCount;