日期:2014-05-20  浏览次数:20693 次

帮忙解释一下语句
如下语句:
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));
什么意思,如何解析的,谢谢
------解决方案--------------------
引用:
1.oper(2, (a, b) => a + b)
如何对应
public static int oper(this int a, int b, mydg dg)
三个参数的
2是一个参数,1是一个参数,a+b做为—个匿名方法传递给委托