Merge pull request #4816 from BrzVlad/fix-remoting-exception
[mono.git] / mcs / tests / test-anon-10.cs
1 //
2 // This test exercises the access to a field instance from an instance
3 // method that has an anonymous method.
4 // 
5 using System;
6
7 class S {
8         delegate void T ();
9
10         T t;
11
12         int f;
13
14         public void Test ()
15         {
16                 // The loop just forces the creation of a helper class, so
17                 // that the anonymous method is not placed side-by-side this
18                 // method.
19                 int a = 1;
20                 for (int i = a; i < 10; i++){
21                         int j = i;
22                         t = delegate {
23                                 Console.WriteLine ("Before: {0} {1} {2}", f, i, j);
24                                 f = i;
25                         };
26                 }
27         }
28         
29         public static int Main ()
30         {
31             S s = new S ();
32             s.Test ();
33             s.t ();
34             if (s.f == 10)
35                     return 0;
36             Console.WriteLine ("Failed:" + s.f);
37             return 1;
38         }
39 }
40         
41