fork(1) download
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. var str = "In the end this is not the end";
  9. var counts = new Dictionary<string,int>();
  10. var tokens = str.Split(' ');
  11. for (var i = 0 ; i < tokens.Length-1 ; i++) {
  12. var key = tokens[i]+" "+tokens[i+1];
  13. int c;
  14. if (!counts.TryGetValue(key, out c)) {
  15. c = 0;
  16. }
  17. counts[key] = c + 1;
  18. }
  19. foreach (var p in counts) {
  20. Console.WriteLine("{0} = {1}", p.Key, p.Value);
  21. }
  22. }
  23. }
Success #stdin #stdout 0.04s 33928KB
stdin
Standard input is empty
stdout
In the = 1
the end = 2
end this = 1
this is = 1
is not = 1
not the = 1