arttuladhar
1/13/2012 - 5:45 AM

Multicast Deligate - It is a delegate which holds the reference of more than one method.

Multicast Deligate - It is a delegate which holds the reference of more than one method.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication2
{
    class Program
    {
        delegate void Delegate_Multicase(int x, int y);
            static void Method1(int x, int y)
            {
                Console.WriteLine("You are in Method 1");
                Console.WriteLine("X :" + x + "\nY :" + y);
            }
            static void Method2(int x, int y)
            {
                Console.WriteLine("You are in Method 2");
                Console.WriteLine("X :" + x + "\nY :" + y);
            }
                 
        
        static void Main(string[] args)
        {
            Delegate_Multicase func = new Delegate_Multicase(Method1);
            func += new Delegate_Multicase(Method2);
            func(1, 2);         //Method 1 and 2 are called

            func -= new Delegate_Multicase(Method1);
            func(2, 3);

            Console.ReadLine();     //Pause

        }
    }
}