fork download
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. public class Test
  5. {
  6. static IEnumerator<string> Generate()
  7. {
  8. yield return "A";
  9. yield return "B";
  10. yield return "C";
  11. }
  12.  
  13. public static void Main()
  14. {
  15. using (var iterator = Generate())
  16. while (iterator.MoveNext())
  17. {
  18. Console.WriteLine(iterator.Current);
  19. if (iterator.Current == "B")
  20. {
  21. while (iterator.MoveNext())
  22. Console.WriteLine(" " + iterator.Current);
  23. }
  24. }
  25. }
  26. }
Success #stdin #stdout 0.02s 33808KB
stdin
Standard input is empty
stdout
A
B
    C