fork(8) download
  1. using System;
  2. using System.Linq;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. var listOfGroups = new[] { "a1", "a2", "b1" }
  9. .GroupBy(x => x.Substring(0, 1))
  10. .ToList();
  11.  
  12. var newGroup = new[] { "foo", "bar" }.GroupBy(x => "baz").Single();
  13.  
  14. listOfGroups.Add(newGroup);
  15.  
  16. foreach (var group in listOfGroups)
  17. {
  18. Console.WriteLine(group.Key + ":");
  19. Console.WriteLine(" " + string.Join(", ", group));
  20. }
  21. }
  22. }
Success #stdin #stdout 0.05s 24440KB
stdin
Standard input is empty
stdout
a:
    a1, a2
b:
    b1
baz:
    foo, bar