fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. public class Test
  6. {
  7. public static void Main()
  8. {
  9. int j = 0;
  10. Console.WriteLine(Example().Any());
  11. }
  12.  
  13. public static IEnumerable<int> Example()
  14. {
  15. try
  16. {
  17. for(int i = 0; i < 10; i++)
  18. {
  19.  
  20. Console.WriteLine("Before yield {0}", i);
  21. yield return i;
  22. Console.WriteLine("After yield {0}", i);
  23. }
  24. }
  25. finally
  26. {
  27. Console.WriteLine("In block finally");
  28. }
  29. }
  30. }
Success #stdin #stdout 0.03s 29092KB
stdin
Standard input is empty
stdout
Before yield 0
In block finally
True