2010-02-19 Rodrigo Kumpera <rkumpera@novell.com>
[mcs.git] / tests / test-anon-21.cs
blob7531dfe6145e85d9c9a985fe8f8948604f2db528
1 //
2 // Nested anonymous methods and capturing of variables test
3 //
4 using System;
6 delegate void D ();
8 class X {
10 static int Main ()
12 X x = new X();
13 x.M ();
14 e ();
15 Console.WriteLine ("J should be 101= {0}", j);
16 if (j != 101)
17 return 3;
18 Console.WriteLine ("OK");
19 return 0;
22 static int j = 0;
23 static D e;
25 void M ()
27 int l = 100;
29 D d = delegate {
30 int b;
31 b = 1;
32 Console.WriteLine ("Inside d");
33 e = delegate {
34 Console.WriteLine ("Inside e");
35 j = l + b;
36 Console.WriteLine ("j={0} l={1} b={2}", j, l, b);
39 Console.WriteLine ("Calling d");
40 d ();