fork(7) download
  1. using System;
  2. using System.Linq;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. string str = "Split handles splitting upon string and character delimiters.";
  9. var pairs = str.Split(' ')
  10. .Select((s,i) => new {s, i})
  11. .GroupBy(n => n.i / 2)
  12. .Select(g => string.Join(" ", g.Select(p=>p.s).ToArray()))
  13. .ToList();
  14. foreach (var s in pairs)
  15. Console.WriteLine(s);
  16.  
  17.  
  18. }
  19. }
Success #stdin #stdout 0.05s 34200KB
stdin
Standard input is empty
stdout
Split handles
splitting upon
string and
character delimiters.