asp.net core 委托

两种委托的写法

      // 声明委托
        public delegate int MyMethod(int i, int n);

        public IActionResult Wt1()
        {
            MyMethod myMethod = (int i, int n) =>
            {
                return i + n;
            };

            return Json(myMethod(2, 2));
        }

        public IActionResult Wt2()
        {
            Func<int, int, string> func = (i, n) =>
            {
                int s = i + n;
                return s.ToString();
            };

            return Json(func(1,2));
        }

猜你喜欢

转载自www.cnblogs.com/mountaincat/p/11073440.html