2009-01-24 Zoltan Varga <vargaz@gmail.com>
[mcs.git] / tests / test-anon-20.cs
blobda92400d7c488c607f377f5db70acb7898206317
1 //
2 // Nested anonymous methods tests and capturing of different variables.
3 //
4 using System;
6 delegate void D ();
8 class X {
9 static D GlobalStoreDelegate;
11 static void Main ()
13 D d = MainHost ();
15 d ();
16 GlobalStoreDelegate ();
17 GlobalStoreDelegate ();
20 static D MainHost ()
22 int toplevel_local = 0;
24 D d = delegate () {
25 int anonymous_local = 1;
27 GlobalStoreDelegate = delegate {
28 Console.WriteLine ("var1: {0} var2: {1}", toplevel_local, anonymous_local);
29 anonymous_local = anonymous_local + 1;
32 toplevel_local = toplevel_local + 1;
35 return d;