C#???????????
???????????? ???????[ 2016/2/18 10:25:18 ] ????????.NET ???????????
???????????C#????????????胁??????????????????????????????????????????些???????????
?????.C?????械????????
????????????????校???????????????睢�??谓?????????????????????????-.-???????????????????????square??cube??????????????????????????????????搴�?????calcu?????????calcu???square?????????calcu??????????square??????????????????????????????????????????锟�???????????????????????
1 #include <stdio.h> 2 3 void square(int x) { printf("square of %d is %d "??x??x*x); } 4 void cube(int x) { printf("cube of %d is %d "??x??x*x*x); } 5 6 int main() 7 { 8 void (*calcu)(int x); 9 calcu=square; 10 calcu(2); 11 12 return 0; 13 }
??????.C#????械????
??????????????????????C#奴??????????????C#?????????????????????????????????????????搴�?????????????????效???????????????????????谓??????????????C?械??????????????????????????
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 class Program 10 { 11 static void square(int x) { Console.WriteLine("square of {0} is {1}"?? x?? x * x); } 12 static void cube(int x) { Console.WriteLine("cube of {0} is {1}"?? x?? x * x * x); } 13 14 delegate void math(int x); //??????????? 15 16 static void Main(string[] args) 17 { 18 math calcu; 19 calcu += square; 20 calcu(2); 21 Console.ReadKey(); 22 } 23 } 24 }
????????????????????????math??????????????void*????????????????????????calcu???????????????????????????搴�????????????????static????????煤??????未?????????芯???????????????????????
??????.??械???梅???
??????????????????19?泻????????写??? calcu+=cube; ???谢????square??cube???????谩?????????????? += ?????????????斜??????????? -= ??????????????????calcu??void **????????????????????椋�?????械????????????????????蔚???calcu????????????椋�?????蔚???????????????
??????

???路???
??????????????????
2023/3/23 14:23:39???写?貌??????????
2023/3/22 16:17:39????????????????????些??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???路???????路
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11