summaryrefslogtreecommitdiff
path: root/mcs/tests/test-anon-07.cs
blob: 5c08e5e4726f423af4e69f9774f01cdb9bd52714 (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
//
// Tests havign more than one anonymous method that captures the same variable
//
using System;

delegate void D ();

class X {
	public static int Main ()
	{
		int a = 0;
		D d1 = delegate {
			Console.WriteLine ("First");
			a = 1;
		};
		
		D d2 = delegate {
			Console.WriteLine ("Second");
			a = 2;
		};
		if (!t (a, 0))
			return 1;
		d1 ();
		if (!t (a, 1))
			return 2;
		d2 ();
		if (!t (a, 2))
			return 3;
		Console.WriteLine ("Test passes OK");
		return 0;
	}

	static bool t (int a, int b)
	{
		return a == b;
	}
}