两种委托的写法
- // 声明委托
- 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));
- }
来源: http://www.bubuko.com/infodetail-3101540.html