using System.Collections.Generic;
public Dictionary<string, int> GetWordsFrequencyCount(string text)
Dictionary<string, int> GWFC = new Dictionary<string, int>();
for (int i = 0; i < text.Length; i++)
if (i == text.Length - 1)
public Dictionary<int,int> GetWordsLengthFrequencyCount(string text)
Dictionary<int, int> GWLFC = new Dictionary<int, int>();
for (int i = 0; i < text.Length; i++)
if (i == text.Length - 1)
GWLFC.Add(Word.Length, 1);
GWLFC.Add(Word.Length, 1);
public static void Main(string[] args)
Program p = new Program();
Dictionary<string, int> ReturnedGWFC = p.GetWordsFrequencyCount("My bike and my book");
Dictionary<int, int> ReturnedGWLFC = p.GetWordsLengthFrequencyCount("My bike and my book");
foreach (KeyValuePair<string, int> val in ReturnedGWFC)
if (val.Key == ReturnedGWFC.Keys.Last()) Console.WriteLine("\"{0}\": {1}", val.Key, val.Value);
else Console.Write("\"{0}\": {1}, ", val.Key, val.Value);
foreach (KeyValuePair<int, int> val in ReturnedGWLFC)
if (val.Key == ReturnedGWLFC.Keys.Last()) Console.WriteLine("{0}: {1}", val.Key, val.Value);
else Console.Write("{0}: {1}, ", val.Key, val.Value);