手机
当前位置:查字典教程网 >编程开发 >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#(Socket)同步套接字代码示例

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

C#下解析HTML的两种方法介绍

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

c#中利用委托反射将DataTable转换为实体集的代码

C#中使用Socket获取网页源代码的代码

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

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

C#中使用split分割字符串的几种方法小结

精品推荐
分类导航