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. int [] arr = { 3, 2, 1, 6, 5, 6 };
  10. var closures = new List<Action>();
  11. foreach (var i in arr)
  12. closures.Add(() => Console.WriteLine(i));
  13.  
  14. foreach (var run in closures)
  15. run();
  16. }
  17. }
Success #stdin #stdout 0.03s 33784KB
stdin
Standard input is empty
stdout
6
6
6
6
6
6