fork download
  1. using System;
  2.  
  3. class Program {
  4. static void Main() {
  5. Action closure = Test();
  6. closure();
  7. closure();
  8. }
  9. static Action Test() {
  10. Closure local = new Closure();
  11. local.counter = 0;
  12. return local.Function;
  13. }
  14. }
  15. //gerado pelo compilador
  16. class Closure {
  17. public int counter;
  18. public void Function() => Console.WriteLine(counter++);
  19. }
  20.  
  21. //https://pt.stackoverflow.com/q/580366/101
Success #stdin #stdout 0.05s 24944KB
stdin
Standard input is empty
stdout
0
1