fork(1) download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. public class Test
  6. {
  7. class Bagor {
  8. public int i=0;
  9. public static Bagor operator ++(Bagor a)
  10. {
  11. a.i += 1;
  12. return a;
  13. }
  14. public override string ToString()
  15. {
  16. return "" + i;
  17. }
  18. }
  19.  
  20. public static void Main()
  21. {
  22. var actions = new List<Action>();
  23.  
  24. for (var it = new Bagor(); it.i<3; it++ )
  25. {
  26. actions.Add(() => Console.WriteLine(it));
  27. }
  28.  
  29. foreach (var action in actions)
  30. {
  31. action();
  32. }
  33. }
  34. }
Success #stdin #stdout 0.02s 22568KB
stdin
Standard input is empty
stdout
3
3
3