예제 #1
0
        static void Main(string[] args)
        {
            Adder a = new Adder();

            a.OnMultipleOfFiveReached += new Adder.dgEventRaiser(a_MultipleOfFiveReached);

            int iAnswer = a.Add(4, 3);

            Console.WriteLine("iAnswer = {0}", iAnswer);
            iAnswer = a.Add(4, 6);
            Console.WriteLine("iAnswer = {0}", iAnswer);
            Console.ReadKey();
        }
예제 #2
0
        static void Main(string[] args)
        {
            Adder a     = new Adder();
            var   lover = new MultiplesOfFiveLover();



            //a.OnMultipleOfFiveReached += new Adder.DgEventRaiser(lover.MultipleOfFiveReached);
            a.OnMultipleOfFiveReached += lover.MultipleOfFiveReached;
            a.OnMultipleOfFiveReached += Console.WriteLine;

            var answer = a.Add(4, 3);

            Console.WriteLine("Answer = {0}", answer);

            answer = a.Add(4, 6);
            Console.WriteLine("Answer = {0}", answer);

            a.OnMultipleOfFiveReached -= lover.MultipleOfFiveReached;

            Console.WriteLine("Answer = {0}", a.Add(3, 2));

            Console.ReadKey();
        }