delegate 笔记01
来源:互联网 发布:fifaaddict数据库 编辑:程序博客网 时间:2024/05/16 03:30
using System;namespace test{ class ABC { public int a {get;set;} public int b {get;set;} public int ret() { return a+b; } } class Program { public delegate string GetAString(); public delegate int GetSum(int a, int b); public delegate int GetABC(); public static int sum(int a, int b) { return a + b; } static void Main(string[] args) { int x = 40; GetAString firstStringMethod = new GetAString(x.ToString); Console.WriteLine("String is {0}", firstStringMethod()); //Output: String is 40 x = 55; Console.WriteLine("String is {0}", firstStringMethod.Invoke()); //Output: String is 40 ABC abc = new ABC(); abc.a = 3; abc.b = 4; GetABC firstABCMethod = new GetABC(abc.ret); Console.WriteLine("Sum is {0}", firstABCMethod()); //Output: Sum is 7 abc.a = 5; abc.b = 6; Console.WriteLine("Sum is {0}", firstABCMethod()); //Output: Sum is 11 int a = 3; int b = 4; GetSum firstSumMethod = new GetSum(sum); Console.WriteLine("Sum is {0}", firstSumMethod(a, b)); //Output: Sum is 7 Console.WriteLine("Sum is {0}", firstSumMethod.Invoke(a, b)); //Output: Sum is 7 Console.Read(); } }}
0 0
- delegate 笔记01
- delegate笔记
- delegate学习笔记
- 学习代理 笔记 delegate
- 学习笔记 - protocol,delegate
- C#学习笔记-delegate 委托
- QT笔记:代理(Delegate)小结
- IOS 笔记 - navigationController delegate 劫持
- iOS学习笔记3---delegate五步曲,轻松学会使用delegate
- delegate
- delegate
- Delegate
- delegate
- Delegate
- Delegate
- Delegate
- Delegate
- delegate
- 有线网络(网关等)和无线网络通信(蓝牙跳频通信等)讲解
- SpringMVC简单配置
- Insert Interval
- 关于ScrollView嵌套RecycleView的问题。
- XML之命名空间的作用(xmlns)
- delegate 笔记01
- 【基础算法】最长上升子序列
- android平台短视频技术之 视频编辑的经验分享
- 关于starrydb要做的---未来的语言,数据存储和运算
- join查询
- C# 将 txt 文件拖拽到 textbox时 textbox 读取txt中文本内容
- 红外遥控协议-NEC协议
- Party (Standard IO)
- Java实现文件远程上传和下载