blob: 21fe237a934697bde738795aa8cc36e4b4494a03 (
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
|
//
// This test checks various uses of captured local variables
//
using System;
delegate void S ();
class X {
static int Main ()
{
int a = 1;
Console.WriteLine ("A is = " + a);
int c = a;
Console.WriteLine (c);
if (a != 1){
return 1;
}
S b = delegate {
if (a != 1)
Environment.Exit (1);
Console.WriteLine ("in Delegate");
a = 2;
if (a != 2)
Environment.Exit (2);
Console.WriteLine ("Inside = " + a);
a = 3;
Console.WriteLine ("After = " + a);
};
if (a != 1)
return 3;
b ();
if (a != 3)
return 4;
Console.WriteLine ("Back, got " + a);
Console.WriteLine ("Test is ok");
return 0;
}
}
|