C#???????????
???????????? ???????[ 2016/2/18 10:25:18 ] ????????.NET ???????????
??????.??????????????
????????????????????????????????????з??????????????
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 }
??????????????????????????
????????????????????????ò?????????????????????????????????????ɡ?
??????
???·???
App??С????H5?????????????????Щ??
2024/9/11 15:34:34?????????????????????????
2024/9/10 11:13:49P-One ???????????????????????????????????????
2024/9/10 10:14:12???????????????????????????
2024/9/9 18:04:26??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44

sales@spasvo.com