Welcome to mirror list, hosted at ThFree Co, Russian Federation.

test-anon-10.cs « tests « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: bee3519ea97ada57441ae27c63b95cc4a8a5e6d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//
// This test exercises the access to a field instance from an instance
// method that has an anonymous method.
// 
using System;

class S {
	delegate void T ();

	T t;

	int f;

	public void Test ()
	{
		// The loop just forces the creation of a helper class, so
		// that the anonymous method is not placed side-by-side this
		// method.
		int a = 1;
		for (int i = a; i < 10; i++){
			int j = i;
			t = delegate {
				Console.WriteLine ("Before: {0} {1} {2}", f, i, j);
				f = i;
			};
		}
	}
	
	public static int Main ()
	{
	    S s = new S ();
	    s.Test ();
	    s.t ();
	    if (s.f == 10)
		    return 0;
	    Console.WriteLine ("Failed:" + s.f);
	    return 1;
	}
}