unc<T, TResult> Delegate 在3.5以上版本可用.
个人理解:不用再事先声明一个delegate的类型了.可以直接用,也可以用lamba调用 .参数1:委托类型,参数二:返回类型
Eg1;传统型的.
using System;
delegate string ConvertMethod(string inString);
public class DelegateExample
{
public static void Main()
{
// Instantiate delegate to reference UppercaseString method
ConvertMethod convertMeth = UppercaseString;
string name = "Dakota";
// Use delegate instance to call UppercaseString method
Console.WriteLine(convertMeth(name));
}
private static string UppercaseString(string inputString)
{
return inputString.ToUpper();
}
}
//个人理解:1.代理在用的时候要实例化,
2.被调用的方法必须是static的。
3.代理的定义不能在public,private
4.返回类型要相同(string), 参数类型要相同。