using System;

namespace LinQAndDeleGate
{
    class Program
    {
        static void Main(string[] args)
        {
            var func = new Func<int, int, int>((int a, int b) => { return a + b; }); //Lambda表达式,匿名函数
            Func<int,int,int> func2 = (a,b) => { return a * b; }; //参数类型可省略
            var res = func(1, 3);
            Console.WriteLine(res);
            Dosome((a, b) => { return a * b; }, 100, 200);//Lambda表达式

        }
        static void Dosome<T>(Func<T,T,T>func,T x,T y) //泛型方法+泛型委托类型参数
        {
            T res = func(x, y);
            Console.WriteLine(res);
        }

    }
}

最后修改:2022 年 12 月 05 日
如果觉得我的文章对你有用,请随意赞赏