fork(1) download
  1. using System;
  2. using System.Globalization;
  3. using System.Linq;
  4. using System.Collections.Generic;
  5. using System.Diagnostics;
  6. using System.Text;
  7.  
  8. public class Test
  9. {
  10. public static void Main()
  11. {
  12. var originalList = new List<string>(){"split","1","split","2","2","split","3","3","3"};
  13. var result = new List<List<string>>();
  14. List<string> subList = new List<string>();
  15. foreach(string str in originalList)
  16. {
  17. if(str=="split")
  18. {
  19. subList = new List<string>();
  20. result.Add(subList);
  21. }
  22. subList.Add(str);
  23. }
  24. foreach(List<string> chunk in result)
  25. Console.WriteLine("[{0}]",string.Join(",", chunk.ToArray()));
  26. }
  27. }
  28.  
Success #stdin #stdout 0.03s 33960KB
stdin
Standard input is empty
stdout
[split,1]
[split,2,2]
[split,3,3,3]