fork download
  1. using static System.Console;
  2. using System.Collections;
  3.  
  4. public class Program {
  5. static int[] array = new int[]{1, 2, 3, 4, 5 };
  6. public static void Main() {
  7. var o = Teste();
  8. if (o != null) {
  9. WriteLine("Continuando...");
  10. while (o.MoveNext()) WriteLine(o.Current);
  11. }
  12. }
  13. static IEnumerator Teste() {
  14. IEnumerator o = array.GetEnumerator();
  15. while (o.MoveNext()) {
  16. WriteLine(o.Current);
  17. if ((int)o.Current > 2) return o;
  18. }
  19. return null;
  20. }
  21. }
  22.  
  23. //https://pt.stackoverflow.com/q/191222/101
Success #stdin #stdout 0.02s 16240KB
stdin
Standard input is empty
stdout
1
2
3
Continuando...
4
5