Beispiel #1
0
        static void Main(string[] args)
        {
            // Create an adder.
            Adder a = new Adder();

            // Assign a method to the event.
            DoneAddingDelegate del = new DoneAddingDelegate(a.AddingComplete);
            Console.WriteLine("Delegate target: {0}", del.Target.ToString());
            Console.WriteLine("Delegate method name: {0}", del.Method.Name);

            // Trigger the event.
            Console.WriteLine("\nSum of 10 and 10 is: {0}", a.Add(10, 10));
            del.DynamicInvoke(null);
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            // Create an adder.
            Adder a = new Adder();

            // Assign a method to the event.
            DoneAddingDelegate del = new DoneAddingDelegate(a.AddingComplete);

            Console.WriteLine("Delegate target: {0}", del.Target.ToString());
            Console.WriteLine("Delegate method name: {0}", del.Method.Name);

            // Trigger the event.
            Console.WriteLine("\nSum of 10 and 10 is: {0}", a.Add(10, 10));
            del.DynamicInvoke(null);
        }