Multicast Delegate
It is a delegate which holds the reference of more than one method.
Multicast delegates must contain only methods that return void, else there is a run-time exception.
Simple Program using Multicast Delegate
delegate void Delegate_Multicast(int x, int y);
Class Class2
{
static void Method1(int x, int y)
{
Console.WriteLine("You r in Method 1");
}
static void Method2(int x, int y)
{
Console.WriteLine("You r in Method 2");
}
public static void <place w:st="on" />Main</place />()
{
Delegate_Multicast func = new Delegate_Multicast(Method1);
func += new Delegate_Multicast(Method2);
func(1,2); // Method1 and Method2 are called
func -= new Delegate_Multicast(Method1);
func(2,3); // Only Method2 is called
}
}
Explanation
In the above example, you can see that two methods are defined named method1 and method2 which take two integer parameters and return type as void.
In the main method, the Delegate object is created using the following statement:
Delegate_Multicast func = new Delegate_Multicast(Method1);
Then the Delegate is added using the += operator and removed using the -= operator.
Reference for knowing when & how to use delegates
http://stackoverflow.com/questions/2019402/when-why-to-use-delegates
http://stackoverflow.com/questions/31497/where-do-i-use-delegates?lq=1 Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif
Sudhakar_A, if this helps please login to Mark As Answer. | Alert Moderator