手机
当前位置:查字典教程网 >编程开发 >C#教程 >C#中使用委托的3种方式代码示例
C#中使用委托的3种方式代码示例
摘要:usingSystem;namespaceDelegateDemo{classProgram{privatedelegateintCacu(...

using System; namespace DelegateDemo { class Program { private delegate int Cacu(string str); static void Main(string[] args) { //1 Cacu cacu = new Cacu(CacuInstance); Console.WriteLine(cacu("Hello,Wrold")); //2 Cacu cacu1 = new Cacu(delegate(string str) { return str.Length; }); Console.WriteLine(cacu1("Hello,Wrold")); //3 Cacu cacu2 = new Cacu((str) => { return str.Length; }); Console.WriteLine(cacu2("Hello,Wrold")); } static int CacuInstance(string str) { return str.Length; } } }

【C#中使用委托的3种方式代码示例】相关文章:

C#仿密保卡功能的简单实现代码

C#生成注册码的实例代码

C#中的yield关键字的使用方法介绍

c#中使用自动属性减少代码输入量

C#定位txt指定行的方法小例子

C# 委托(delegate) 的小例子

C#中通过API实现的打印类 实例代码

c#(Socket)同步套接字代码示例

基于使用BeginInvoke,EndInvoke异步调用委托的实现代码

简介C#读取XML的两种方式

精品推荐
分类导航