系统内置的泛型委托

#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

posted on 2014-11-02 15:23  木屐  阅读(142)  评论(0编辑  收藏  举报

导航