public delegate TR Func<T1, T2, TR>(T1 p1, T2 p2); //泛型委托 TR委托返回类型 T1,T2 委托参数类型
class Simple
{
static public string PrintString(int p1, int p2) //方法匹配委托
{
int total = p1 + p2;
return total.ToString();
}
}
class Program
{
static void Main()
{
var myDel = new Func <int, int, string>(Simple.PrintString); //创建委托实例
Console.WriteLine("ToTal: {0}", myDel(15, 13));// 调用委托
}
}