Move Enum and CorElementType to shared (dotnet/coreclr#23177)
[mono-project.git] / mcs / tests / test-364.cs
blobdbfb6e142eea5cd3dcace2f0b936c0a402abde45
1 //
2 // Test for bug: 69614
3 //
4 // Basically, this tests that we can capture parameters and use them outside the delegate
5 //
6 using System;
8 class X {
10 delegate int Foo ();
12 public static int Main ()
14 int x = t1 (1);
15 if (x != 1)
16 return 1;
17 x = t2 (2);
18 if (x != 3)
19 return 2;
20 return 0;
23 static int t1 (int p)
25 Foo f = delegate {
26 return p;
28 return f ();
31 static int t2 (int p)
33 p++;
34 Foo f = delegate {
35 return p;
37 return f ();
41 // This is just here to check that it compiles, but the logic is the
42 // same as the ones before
44 public static void Main2 (string[] argv)
46 Console.WriteLine ("Test");
48 Delegable db = new Delegable ();
49 if (argv.Length > 1) {
50 db.MyDelegate += delegate (object o, EventArgs args) {
51 Console.WriteLine ("{0}", argv);
52 Console.WriteLine ("{0}", db);
58 class Delegable {
59 public event EventHandler MyDelegate;