Multicast delegate is an extension of normal delegate. It helps you to point more than one method at a single moment of time.
Multicast Delegate
Example for multicast delegate to invoke instance methods
namespace multicastdelegateex1
{
class Myclass
{
internal void method1()
{
console.writeline("method1 is calling");
}
internal void method2()
{
console.writeline("method2 is calling");
}
}
internal delagate void MultiDelegate();
class Program
{
void main()
{
Myclass obj=new Myclass(0;
MultiDelegate delobj=new MultiDelegate(obj.method1);
delobj+=new MultiDelegate(obj.Method2);
delobj();
delob-=new MultiDelegate(obj.method2);
delobj();
console.ReadLine();
}
Output:
method1 is calling
method2 is calling
method2 is calling
method1 is calling
method1 is calling
Friends you like my post please share to your friends because sharing is caring.Share the post through social media like Facebook,Twitter,Google+ etc.And you feel free comment on post do you have any doubts i clarify your doubts.
whats the use of multicast delegate
ReplyDeleteMulticast delegate is an extension of normal delegate. It helps you to point more than one method at a single moment of time.
DeleteMulticast delegate is an extension of normal delegate. It helps you to point more than one method at a single moment of time.
ReplyDelete