摘要: Action和Func是微软已经定义好的的两种委托类型,区别是Action是没有返回值的,而Func是需要返回值的。 1 //Action内置委托的实例化及调用 2 //不带参数 3 Action myAction1 = () => { Console.WriteLine("这是一个Action委托 阅读全文
posted @ 2020-06-24 22:12 摩诘 阅读(394) 评论(0) 推荐(0) 编辑
摘要: 1 delegate void NumberCalculator(int a); 2 class Program 3 { 4 static int num1 = 100; 5 static void Main(string[] args) 6 { 7 /*1、委托的多播*/ 8 NumberCalc 阅读全文
posted @ 2020-06-24 21:45 摩诘 阅读(216) 评论(0) 推荐(0) 编辑
摘要: 总结:委托使用,归纳有三个过程:1、声明委托;2、实例化委托;3、调用委托。也可以简化使用。 //声明一个委托 delegate int NumberCalculator(int a, int b); class Program { static int num1 = 3; static int n 阅读全文
posted @ 2020-06-24 19:26 摩诘 阅读(112) 评论(0) 推荐(0) 编辑