**** Merged from MCS ****
[mono-project.git] / mcs / tests / 2test-a6.cs
blobe34d61f6053d736f5e5ec0f5f901a4a4fa3c2ecd
1 //
2 // Tests capturing of double nested variables
3 //
4 delegate void S ();
5 using System;
7 class X {
8 static int Main ()
10 int i;
11 S b = null;
13 for (i = 0; i < 10; i++){
14 int j = 0;
15 b = delegate {
16 Console.WriteLine ("i={0} j={1}", i, j);
17 i = i + 1;
18 j = j + 1;
21 b ();
22 Console.WriteLine ("i = {0}", i);
23 if (!t (i, 11))
24 return 1;
25 b ();
26 if (!t (i, 12))
27 return 2;
28 Console.WriteLine ("i = {0}", i);
29 return 0;
32 static bool t (int a, int b)
34 return a == b;