1 public class delegate void ClassDelegate(int x);
2
3 public class Alpha
4 {
5 public void foo(int x)
6 {
7 System.Console.WriteLine("foo called with " + System.ToString(x));
8 }
9 public void bar(int x)
10 {
11 System.Console.WriteLine("bar called with " + System.ToString(x));
12 }
13 public void baz()
14 {
15 barDlg = bar;
16 }
17 public void fuz()
18 {
19 barDlg(24);
20 }
21 private ClassDelegate barDlg;
22 }
23
24 public void main()
25 {
26 Alpha alpha;
27 ClassDelegate fooDlg = alpha.foo;
28 fooDlg(42);
29 alpha.baz();
30 alpha.fuz();
31 }