码迷,mamicode.com
首页 > 其他好文 > 详细

系统内置的泛型委托

时间:2014-11-02 16:20:53      阅读:207      评论:0      收藏:0      [点我收藏+]

标签:io   os   使用   sp   on   cti   bs   ad   line   

#region 系统内置的泛型委托
//只要是Action委托都是无返回值的。

////1.存储无参数无返回值的方法
//Action md = () => { Console.WriteLine("无参数无返回值。"); };
//md();
//Console.Read();


////2.有一个参数没有返回值
//Action<string, int> md = (s, i) => { Console.WriteLine(s + " " + i); };
//md("aaaaaaa", 10);
//Console.Read();

 

//当需要存储带返回值的方法的时候,就需要使用另外一个泛型委托Func


//Func<string> fn = T1;

//string ss = fn();
//Console.WriteLine(ss);
//Console.Read();


////返回值是string类型,参数是一个int类型
//Func<int, string> fn = n => n.ToString();
//Console.WriteLine(fn(10));
//Console.Read();

//Func<int, int, string> fn = T2;
//Console.WriteLine(fn(12, 5));
//Console.Read();

//Action<string>
#endregion

系统内置的泛型委托

标签:io   os   使用   sp   on   cti   bs   ad   line   

原文地址:http://www.cnblogs.com/poli/p/4069312.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!