手机
当前位置:查字典教程网 >编程开发 >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#的XML两种代码注释实例说明

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

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

C#位移的介绍与例子

使用C#实现在屏幕上画图效果的代码实例

C# 委托(delegate) 的小例子

c#一个定时重启的小程序实现代码第1/2页

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

用C#写的ADSL拨号程序的代码示例

C#实现的几种委托方式介绍

精品推荐
分类导航