Ejemplo n.º 1
0
        public static void Case1()
        {
            Console.WriteLine("Case 1 : \n");

            DOperation d = Add;

            d(10, 20);
            d = Subtract;
            d(30, 20);
            d = Division;
            d(10, 2);
        }
Ejemplo n.º 2
0
        public static void Case2()
        {
            Console.WriteLine("\nCase 2 : \n");

            DOperation[] delegates = new DOperation[3];
            delegates[0] = (a, b) => Add(a, b);
            delegates[1] = (a, b) => Subtract(a, b);
            delegates[2] = (a, b) => Division(a, b);

            foreach (DOperation ds in delegates)
            {
                ds(40, 5);
            }
        }