blob: 065f7c2cae5bf95eb531e2809dfbb4114c486b7d (
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;
};
}
}
static int Main ()
{
S s = new S ();
s.Test ();
s.t ();
if (s.f == 10)
return 0;
Console.WriteLine ("Failed:" + s.f);
return 1;
}
}
|