blob: d27786db7a9fc9e02efe7a287112d6cf6cf27b5e (
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
//
// Test for bug: 69614
//
// Basically, this tests that we can capture parameters and use them outside the delegate
//
using System;
class X {
delegate int Foo ();
static int Main ()
{
int x = t1 (1);
if (x != 1)
return 1;
x = t2 (2);
if (x != 3)
return 2;
return 0;
}
static int t1 (int p)
{
Foo f = delegate {
return p;
};
return f ();
}
static int t2 (int p)
{
p++;
Foo f = delegate {
return p;
};
return f ();
}
//
// This is just here to check that it compiles, but the logic is the
// same as the ones before
static void Main2 (string[] argv)
{
Console.WriteLine ("Test");
Delegable db = new Delegable ();
if (argv.Length > 1) {
db.MyDelegate += delegate (object o, EventArgs args) {
Console.WriteLine ("{0}", argv);
Console.WriteLine ("{0}", db);
};
}
}
}
class Delegable {
public event EventHandler MyDelegate;
}
|