class Program
{
static void Main(string[] args)
{
//DoSomeCalc<int>((int a,int b) => { return a * b; }, 3, 4);
//泛型委托的类型参数推断:类型Int 可以不写,原因是通过 200,400这个参数进行推断,系统默认是int类型。
DoSomeCalc((a, b) => { return a * b; }, 200, 400);
Console.ReadLine();
}
static void DoSomeCalc<T>(Func<T,T,T> func,T x, T y)
{
T res = func(x, y);
Console.WriteLine(res);
}
}
C# 泛型委托Lambda表达式进行结合
最新推荐文章于 2024-06-18 14:35:37 发布