帮忙解释一下话语
帮忙解释一下语句
如下语句:
谁能解释下
------解决方案--------------------
2是一个参数,1是一个参数,a+b做为—个匿名方法传递给委托
如下语句:
using System;
namespace ConsoleTest
{
public delegate int mydg(int a, int b);
public static class LambdaTest
{
public static int oper(this int a, int b, mydg dg)
{
return dg(a, b);
}
}
class Program
{
static void Main(string[] args)
{
Console.WriteLine(1.oper(2, (a, b) => a + b));
Console.WriteLine(2.oper(1, (a, b) => a - b));
Console.WriteLine(5.oper(3, (c, d) => c * d));
Console.WriteLine("按任意键结束...");
Console.ReadKey();
}
}
}
谁能解释下
Console.WriteLine(1.oper(2, (a, b) => a + b));什么意思,如何解析的,谢谢
Console.WriteLine(2.oper(1, (a, b) => a - b));
Console.WriteLine(5.oper(3, (c, d) => c * d));
------解决方案--------------------
2是一个参数,1是一个参数,a+b做为—个匿名方法传递给委托