??????.??????????????
????????????????????????????????????з??????????????

1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.Threading.Tasks;
6
7 namespace Delegate
8 {
9     public delegate void math(int x);
10     public class Calcu
11     {
12         public math calcu;
13     }
14
15     class Program
16     {
17         static void square(int x) { Console.WriteLine("square of {0} is {1}"?? x?? x * x); }
18         static void cube(int x) { Console.WriteLine("cube of {0} is {1}"?? x?? x * x * x); }
19
20         static void Main(string[] args)
21         {
22             Calcu c = new Calcu();
23             c.calcu += square;
24             c.calcu += cube;
25             c.calcu(2);
26             Console.ReadKey();
27         }
28     }
29 }

??????????б?????public?????????????????????????????????????????C#???????????
??????ν???????????????е?????????????????????Щ???壬?????Щ???????????????????????????private???????б??????????????????????á?
???????????????????????12?и????????
????public event math calcu;
???????????25?б?????????calcu??private????????????á???23??24?в???б????????????????????????????+=????calcu?????????
????????????????????????????????飬????????????????????????????????????public?????????????+=??-=??????????????????????
??????????????????д?????????????????

1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.Threading.Tasks;
6
7 namespace Delegate
8 {
9     public delegate void math(int x);
10     public class Calcu
11     {
12         public event math calcu;
13         public void calculate(int x)
14         {
15             calcu(x);
16         }
17     }
18
19     class Program
20     {
21         static void square(int x) { Console.WriteLine("square of {0} is {1}"?? x?? x * x); }
22         static void cube(int x) { Console.WriteLine("cube of {0} is {1}"?? x?? x * x * x); }
23
24         static void Main(string[] args)
25         {
26             Calcu c = new Calcu();
27             c.calcu += square;
28             c.calcu += cube;
29             c.calculate(2);
30             Console.ReadKey();
31         }
32     }
33 }

??????????????????????????
????????????????????????ò?????????????????????????????????????ɡ?