2010-04-07 Jb Evain <jbevain@novell.com>
[mcs.git] / tests / test-anon-05.cs
blobfe456bede026f0c28b891292624c3a69bf5c9c28
1 //
2 // Tests capturing of double nested variables
3 //
4 using System;
5 delegate void S ();
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 Console.WriteLine ("i = {0}", i);
22 b ();
23 Console.WriteLine ("i = {0}", i);
24 if (!t (i, 11))
25 return 1;
26 b ();
27 if (!t (i, 12))
28 return 2;
29 Console.WriteLine ("i = {0}", i);
30 Console.WriteLine ("Test is OK");
31 return 0;
34 static bool t (int a, int b)
36 return a == b;