fork download
  1. using static System.Console;
  2. using System;
  3. using System.Collections.Generic;
  4.  
  5. public class Program {
  6. public static void Main() {
  7. var lista = new List<Action>();
  8. for (var i = 0; i < 10; i++) lista.Add(() => WriteLine(i));
  9. for (var c = 0; c < 10; c++) Metodo(lista[c]);
  10. var lista2 = new List<Action>();
  11. for (var i = 0; i < 10; i++) {
  12. var tmp = i;
  13. lista2.Add(() => WriteLine(tmp));
  14. }
  15. for (var c = 0; c < 10; c++) Metodo(lista2[c]);
  16. }
  17. public static void Metodo(Action func) => func();
  18. }
  19.  
  20. //https://pt.stackoverflow.com/q/156764/101
Success #stdin #stdout 0.02s 16128KB
stdin
Standard input is empty
stdout
10
10
10
10
10
10
10
10
10
10
0
1
2
3
4
5
6
7
8
9