Пример #1
0
        public static void Main()//Main_8_5_1
        {
            Calculator calculator = new Calculator();
            //事件触发者
            CalculatorManager cm = new CalculatorManager();

            //事件绑定
            calculator.MyCalculate += cm.Add;
            calculator.Calculate(100, 200);
            calculator.MyCalculate += cm.Substract;
            calculator.Calculate(100, 200);

            //事件注销
            calculator.MyCalculate -= cm.Add;
            calculator.Calculate(100, 200);
        }
Пример #2
0
        //Main_8_5_1
        public static void Main()
        {
            Calculator calculator = new Calculator();
            //�¼�������
            CalculatorManager cm = new CalculatorManager();

            //�¼���
            calculator.MyCalculate += cm.Add;
            calculator.Calculate(100, 200);
            calculator.MyCalculate += cm.Substract;
            calculator.Calculate(100, 200);

            //�¼�ע��
            calculator.MyCalculate -= cm.Add;
            calculator.Calculate(100, 200);
        }