namespace DelegateTest { public partial class Form1 : Form { BroadcastClass B = new BroadcastClass(); ListenToClass1 L1 = new ListenToClass1(); ListenToCalss2 L2 = new ListenToCalss2(); ListenToClass3 L3 = new ListenToClass3(); public Form1() { InitializeComponent(); // wire methods of one class to the event of a single class B.EventName += new DelegateName(L1.IHeardSomething); B.EventName += new DelegateName(L2.IHeardSomething); B.EventName += new DelegateName(L3.IHeardSomething); } private void Form1_Load(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { B.Start(); } } }
namespace DelegateTest { public partial class Form1 : Form { BroadcastClass B = new BroadcastClass(); ListenToClass1 L1 = new ListenToClass1(); ListenToCalss2 L2 = new ListenToCalss2(); ListenToClass3 L3 = new ListenToClass3(); public Form1() { InitializeComponent(); B.EventName += L1.IHeardSomething; B.EventName += L2.IHeardSomething; B.EventName += L3.IHeardSomething; } private void Form1_Load(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { B.Start(); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)