Esempio n. 1
0
        static void Main(string[] args)
        {
            UpOn myUp = new UpOn();
            UpOnHandler myIncDelegate = new UpOnHandler(myUp.Increment);
            int incrResult = myIncDelegate.Invoke(2);
            Console.WriteLine("Increment result: {0}", incrResult);

            UpOnHandler myDecDelegate = myUp.Decrement;
            int decResult = myDecDelegate(2);
            Console.WriteLine("Decrement result: {0}", decResult);
            Console.ReadLine();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            UpOn myUp = new UpOn();
            UpOnHandler myIncDelegate = new UpOnHandler(myUp.Increment);

            UpOnHandler myDecDelegate = myUp.Decrement;

            Console.WriteLine("Multicasting...");
            var myDelegate = myIncDelegate;
            int m = myIncDelegate(1);

            myDelegate += myDecDelegate;
            m = myDelegate(5);

            myDelegate -= myDecDelegate;
            m = myDelegate(1);

            Console.ReadLine();
        }