fork download
  1. using System;
  2. using System.Linq;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. var input = new[] {"moo", "*", "foo", "bar", "baz", "*", "roo",
  9. "moo", "*", "*", "hoot", "*", "boot"};
  10. int index = 0;
  11. var output = input.Select(x => new {Item=x, GroupCondition = x=="*" ? ++index : index}).GroupBy((x)=>x.GroupCondition).Select(x=>x.Select(y=> y.Item));
  12.  
  13. foreach(var item in output)
  14. {
  15. Console.WriteLine(String.Join(" ", item.ToArray()));
  16. }
  17.  
  18.  
  19. }
  20. }
Success #stdin #stdout 0.04s 35088KB
stdin
Standard input is empty
stdout
moo
* foo bar baz
* roo moo
*
* hoot
* boot