4 delegate void SimpleDelegate ();
5 delegate string NotSimpleDelegate (int a);
10 Console.WriteLine ("Test.F from delegate");
12 public static string G (int a) {
14 throw new Exception ("Something went wrong in G");
15 return "G got: " + a.ToString ();
17 public string H (int a) {
19 throw new Exception ("Something went wrong in H");
20 return "H got: " + a.ToString () + " and " + data.ToString ();
26 Test test = new Test ();
27 SimpleDelegate d = new SimpleDelegate (F);
28 NotSimpleDelegate d2 = new NotSimpleDelegate (G);
29 NotSimpleDelegate d3 = new NotSimpleDelegate (test.H);
31 // we run G() and H() before and after using them as delegates
32 // to be sure we don't corrupt them.
35 Console.WriteLine (d2 (2));
36 Console.WriteLine (d3 (3));