Using system;
Namespace Pattern {/// /// summary description for class1. /// summary> public class observer {public observer () {/// Todo: add constructor logic here //} Internal Void Update String name) {console.writeLine (name);}} public class productobj {
public productObj () {} private string name; private observer o; public string getName () {return name;} public void setName (string name) {this.name = name; // set change point notifyObservers (name);} private Void NotifyObserve (String Name) {if (o! = null) o.Update (name);} public void addobserver ({this.o = o;}}
} // Observer mode Productobj P = New Productobj (); P.AddobServer (New Observer ()); P.setname ("Good Moring");