fork(1) 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. var actions = new List<Action>();
  10. foreach (var i in Enumerable.Range(1, 3))
  11. {
  12. var j=i;
  13. actions.Add(() => Console.WriteLine(j));
  14. }
  15.  
  16. foreach (var action in actions)
  17. {
  18. action();
  19. }
  20. }
  21. }
Success #stdin #stdout 0.03s 36976KB
stdin
Standard input is empty
stdout
1
2
3