public void Test() { //进行委托绑定 MyDelegate = new CalculateDelegage(Add); MyDelegate(3, -1); Console.WriteLine("--------------------------------------------"); MyDelegate += Subtract; MyDelegate += Mutilply; MyDelegate += Divide; MyDelegate += Add; MyDelegate(3, -1); Console.WriteLine("--------------------------------------------"); MyDelegate -= Add; MyDelegate(3, -1); Console.WriteLine("--------------------------------------------"); MyDelegate = new CalculateDelegage(Add); MyDelegate(3, -1); Console.ReadKey(); }
public static void Test() { //进行委托绑定 MyDelegate = new CalculateDelegage(CalculatorStatic.Add); MyDelegate(3, -1); Console.WriteLine("--------------------------------------------"); //多播委拖 MyDelegate -= CalculatorStatic.Add; MyDelegate += CalculatorStatic.Add; MyDelegate(1, -1); Console.WriteLine("--------------------------------------------"); Console.ReadKey(); }