日期:2014-05-20 浏览次数:20724 次
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));