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 mainList = new List<string>
  10. {"Reset", "Set", "Test", "Test", "Reset", "Test", "Test"};
  11. var result = string
  12. .Join("|", mainList)
  13. // ^ use a special character/pattern that will never use in your texts
  14. .Replace("Reset", "|@|Reset")
  15. // ^^^ use a special pattern for identifying place of `Reset`
  16. .Split(new [] { "|@|" }, StringSplitOptions.RemoveEmptyEntries)
  17. // at first I split by place of `Reset` to create a list of strings that identifies by `|@|`
  18. .Select(c => c.Split(new[] { "|" }, StringSplitOptions.RemoveEmptyEntries))
  19. // now each string will become a list of strings
  20. .ToList();
  21.  
  22. foreach (var item in result)
  23. {
  24. foreach (var str in item)
  25. {
  26. Console.Write($"{str}, ");
  27. }
  28. Console.WriteLine();
  29. }
  30. }
  31. }
Success #stdin #stdout 0.01s 131648KB
stdin
Standard input is empty
stdout
Reset, Set, Test, Test, 
Reset, Test, Test,