看一个简单的例子:

     //声明一个委托
    delegate int myDelegateHandler(int a, int b);

    public class A
    {
        //静态的处理方法
        public static int M1(int a, int b)
        {
            int c = 0;
            c = a + b;
            return c;
        }
    }
    //入口类
    public class B
    {
        public static void Main()
        {
            //实例一个委托
            myDelegateHandler mdh = new myDelegateHandler(A.M1);
            //调用委托
            int sum = mdh(2, 2);
            Console.WriteLine(sum.ToString());

        }
    }

posted on 2015-01-03 00:44  swarb  阅读(135)  评论(0编辑  收藏  举报