fork download
  1. using System;
  2. using System.Linq;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. var s = new string[] {
  9. "a0|a1|a2|a3|a4|a5|a6|a7|a8|a9|a10|a11|a12",
  10. "b0|b1|b2|b3|b4|b5|b6|b7|b8|b9|b10|b11|b12"
  11. };
  12.  
  13. var result = s.Select(a => a.Split(new[] { '|' }, StringSplitOptions.None))
  14. .Select(a => new {
  15. Column1 = a[2].Trim(),
  16. Column2 = a[5].Trim(),
  17. Column3 = a[6].Trim(),
  18. Column4 = a[11].Trim()
  19. });
  20. foreach (var entry in result)
  21. Console.WriteLine(entry.Column1 + ", " + entry.Column2 + ", "
  22. + entry.Column3 + ", " + entry.Column4);
  23. }
  24. }
Success #stdin #stdout 0.03s 33904KB
stdin
Standard input is empty
stdout
a2, a5, a6, a11
b2, b5, b6, b11