mother.askforcalculate+=new AskForCalculate(son.Calculate);
                 
          son类里面的方法
                     public int Calculate(int a,int b,int c)
        {
            c = a + b;
            return c;
        }        要怎样才能让委托事件里面的方法实行计算  怎样设置委托的参数

解决方案 »

  1.   

    委托就是反过来调用也就是 mother 这个对象负责给你提供 a b c 的值,你照着算就可以了。
      

  2.   

    这样可以使用了啊,定义的委托应该是:delegate int Askforcalculate (int a,int b,int c);
      

  3.   

     public  delegate int AskCalculate(int a,int b,int c);    public class mother
        {
            public  AskCalculate askCalculat;
        }
        public class son
        {
            public static int Calculate(int a, int b, int c)
            {
                c = a + b;            Console.WriteLine("Son.Calculate()中的结果为{0}。",c);
                return c;
            }    }再别的类中使用时:
     mother mo = new mother();
                mo.askCalculat = new AskCalculate(son.Calculate);            int motherResult = mo.askCalculat(1,2,5);
                Console.WriteLine("mother访问 Son中的son.Calculate方法,结果为:{0}",motherResult);
      

  4.   

     public  delegate int AskCalculate(int a,int b,int c);    public class mother
        {
            public  AskCalculate askCalculat;
        }
        public class son
        {
            public static int Calculate(int a, int b, int c)
            {
                c = a + b;            Console.WriteLine("Son.Calculate()中的结果为{0}。",c);
                return c;
            }    }再别的类中使用时:
     mother mo = new mother();
                mo.askCalculat = new AskCalculate(son.Calculate);            int motherResult = mo.askCalculat(1,2,5);
                Console.WriteLine("mother访问 Son中的son.Calculate方法,结果为:{0}",motherResult);
      

  5.   

    mother.askforcalculate的事件一旦激发就会执行该方法的