1 class Subscriber
2 {
3 private string id;
4 public Subscriber(string ID, Publisher pub)
5 {
6 id = ID;
7 // Subscribe to the event using C# 2.0 syntax
8 pub.RaiseCustomEvent += HandleCustomEvent;
9 }
10
11 // Define what actions to take when the event is raised.
12 void HandleCustomEvent(object sender, CustomEventArgs e)
13 {
14 Console.WriteLine(id + " received this message: {0}", e.Message);
15 }
16 }