class Program delegate int testFunc static void Main string args List

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
class Program
{
delegate int testFunc();
static void Main(string[] args)
{
List<testFunc> myList = new List<testFunc>();
for (int i=0; i<2; i++) {
for (int j=0; j<2; j++) {
myList.Add(delegate { return i + j; });
if (i == 1 && j == 1) {
i = 12;
j = 23;
}
}
}
foreach (testFunc f in myList) {
Console.WriteLine(f());
}
}
}