dlr bug
[mcs.git] / tests / test-57.cs
blob9f4c1b82f86920ec9448a703b8ea60e003ce59ec
1 using System;
3 public delegate void EventHandler (int i, int j);
5 public class Button {
7 private EventHandler click;
9 public event EventHandler Click {
10 add { click += value; }
11 remove { click -= value; }
14 public void OnClick (int i, int j)
16 if (click == null) {
17 Console.WriteLine ("Nothing to click!");
18 return;
21 click (i, j);
24 public void Reset ()
26 click = null;
30 public class Blah {
32 Button Button1 = new Button ();
34 public void Connect ()
36 Button1.Click += new EventHandler (Button1_Click);
37 Button1.Click += new EventHandler (Foo_Click);
38 Button1.Click += null;
41 public void Button1_Click (int i, int j)
43 Console.WriteLine ("Button1 was clicked !");
44 Console.WriteLine ("Answer : " + (i+j));
47 public void Foo_Click (int i, int j)
49 Console.WriteLine ("Foo was clicked !");
50 Console.WriteLine ("Answer : " + (i+j));
53 public void Disconnect ()
55 Console.WriteLine ("Disconnecting Button1's handler ...");
56 Button1.Click -= new EventHandler (Button1_Click);
59 public static int Main ()
61 Blah b = new Blah ();
63 b.Connect ();
65 b.Button1.OnClick (2, 3);
67 b.Disconnect ();
69 Console.WriteLine ("Now calling OnClick again");
70 b.Button1.OnClick (3, 7);
72 Console.WriteLine ("Events test passes");
73 return 0;