blob: 9e22abaa27339990a9eeafe65e146f826593e136 (
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
|
//
// Do not extend this test
//
// This test copes with the case where a parameter was already captured
// and a second anonymous method on the same scope captured a parameter
//
using System;
delegate void Del (int n);
class Lambda {
static int v;
static void f (int va)
{
v = va;
}
static Del[] Make2 (int x) {
return new Del[] {
delegate (int a) { f(x += a); },
delegate (int b) { f(x += b); }
};
}
static int Main () {
Del[] d = Make2(10);
d[0](10);
if (v != 20)
return 1;
d[1](11);
if (v != 31)
return 2;
Console.WriteLine ("OK");
return 0;
}
}
|