Back to slide -- Keyboard shortcut: 'u'  previous -- Keyboard shortcut: 'p'        Annotated program -- Keyboard shortcut: 't'    patterns/observer/template/client.cs - Application of the Subject and Observer classes.Lecture 6 - slide 17 : 20
Program 3

using Templates.Observer;
class Client {

  public static void Main(){
     Subject subj = new Subject();                                      
     Observer o1 = new Observer(subj),                                  
              o2 = new Observer(subj),
              o3 = new Observer(subj);

     subj.Attach(o1);  // o1 subscribes to updates from subj.            
     subj.Attach(o2);  // o2 subscribes to updates from subj.

     subj.Notify();    // Following some state changes in subj
                       // notify observers.
  }
}