fork download
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5. public class Test
  6. {
  7. public struct Proc
  8. {
  9. public int ID { get; set; }
  10. public string Value { get; set; }
  11. }
  12.  
  13. public static void Main()
  14. {
  15. var procList = new List<Proc>() {
  16. new Proc{ID=50,Value="process:3333"},new Proc{ID=50,Value="phone:xxxx"},
  17. new Proc{ID=51,Value="process:2222"},new Proc{ID=51,Value="phone:yyyy"},
  18. };
  19. var procIdGroups = procList
  20. .GroupBy(p => p.ID)
  21. .Select(g => new Proc
  22. {
  23. ID = g.Key,
  24. Value = string.Join(",", g.Select(p => p.Value).ToArray())
  25. })
  26. .ToList();
  27.  
  28. foreach(var proc in procIdGroups)
  29. Console.WriteLine("{0} {1}", proc.ID, proc.Value);
  30. }
  31. }
Success #stdin #stdout 0.06s 35048KB
stdin
Standard input is empty
stdout
50 process:3333,phone:xxxx
51 process:2222,phone:yyyy