fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. public class Test
  6. {
  7. public static void Main()
  8. {
  9. var text = "Some example";
  10. var dict = text.GroupBy(c => c).ToDictionary(g => g.Key, g => g.Count());
  11. foreach (var kvp in dict)
  12. Console.WriteLine("Symbol {0}: {1} times", kvp.Key, kvp.Value);
  13. }
  14. }
Success #stdin #stdout 0.06s 24112KB
stdin
Standard input is empty
stdout
Symbol S: 1 times
Symbol o: 1 times
Symbol m: 2 times
Symbol e: 3 times
Symbol  : 1 times
Symbol x: 1 times
Symbol a: 1 times
Symbol p: 1 times
Symbol l: 1 times