* roottypes.cs: Rename from tree.cs.
[mono.git] / mcs / tests / test-anon-20.cs
1 //
2 // Nested anonymous methods tests and capturing of different variables.
3 //
4 using System;
5
6 delegate void D ();
7
8 class X {
9         static D GlobalStoreDelegate;
10         
11         static void Main ()
12         {
13                 D d = MainHost ();
14
15                 d ();
16                 GlobalStoreDelegate ();
17                 GlobalStoreDelegate ();
18         }
19
20         static D MainHost ()
21         {
22                 int toplevel_local = 0;
23                 
24                 D d = delegate () {
25                         int anonymous_local = 1;
26                         
27                         GlobalStoreDelegate = delegate {
28                                 Console.WriteLine ("var1: {0} var2: {1}", toplevel_local, anonymous_local);
29                                 anonymous_local = anonymous_local + 1;
30                         };
31
32                         toplevel_local = toplevel_local + 1;
33                 };
34
35                 return d;
36         }
37 }