5 public delegate int MyDelegate (int i
, int j
);
7 public int Foo (int i
, int j
)
12 public static int Test1 ()
16 MyDelegate del
= new MyDelegate (f
.Foo
);
18 MyDelegate another
= new MyDelegate (del
);
20 int number
= del (2, 3);
22 int i
= another (4, 6);
24 Console
.WriteLine ("Delegate invocation of one returned : " + number
);
26 Console
.WriteLine ("Delegate invocation of the other returned : " + i
);
28 if (number
== 5 && i
== 10)
34 public delegate int List (params int [] args
);
36 public static int Adder (params int [] args
)
40 foreach (int i
in args
)
46 public static int Test2 ()
48 List my_adder
= new List (Adder
);
50 if (my_adder (1, 2, 3) != 6)
56 public static int Main ()
68 Console
.WriteLine ("All tests pass");