How to use MultiCast Delegate using C#.Net

This code demonstrate how to use multicast delegate in C#.Net


public delegate void dname();
class DelegateDemo
{
public void m1()
{
MessageBox.Show("From m1");
}
public void m2()
{
MessageBox.Show("From m2");
}
}

private void button1_Click(object sender, EventArgs e)
{
DelegateDemo obj = new DelegateDemo();
dname d1 = new dname(obj.m1);
dname d2 = new dname(obj.m2);
dname d3;
d3 = d1 + d2;
d3();
}

Regards
S.S.Bajoria


Comments

Author: Pravesh Singh16 Nov 2011 Member Level: Bronze   Points : 1

This is one of the best articles I read online. No crap, just useful information. Very well presented. Check following link too it might be helpful...

http://mindstick.com/Blog/150/Multicast%20Delegate%20in%20C



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: