static void Main(string[] args)
        {
            Console.WriteLine(" ***Observer Pattern Demo***\n");
            //We have 3 observers- 2 of them are ObserverType1, 1 of them is of ObserverType2
            IObserver myObserver1 = new ObserverType1("Roy");
            IObserver myObserver2 = new ObserverType1("Kevin");
            IObserver myObserver3 = new ObserverType2("Bose");
            Subject   subject     = new Subject();

            //Registering the observers-Roy,Kevin,Bose
            subject.Register(myObserver1);
            subject.Register(myObserver2);
            subject.Register(myObserver3);
            Console.WriteLine(" Setting Flag = 5 ");
            subject.Flag = 5;
            //Unregistering an observer(Roy))
            subject.Unregister(myObserver1);
            //No notification this time Roy.Since it is unregistered.
            Console.WriteLine("\n Setting Flag = 50 ");
            subject.Flag = 50;
            //Roy is registering himself again
            subject.Register(myObserver1);
            Console.WriteLine("\n Setting Flag = 100 ");
            subject.Flag = 100;
            Console.ReadKey();
        }
        public StockObserver(Subject stockGrabber)
        {
            this.stockGrabber = stockGrabber;
            observerID        = ++observerIDTracker;

            Console.WriteLine($"New Observer {observerID}");

            stockGrabber.Register(this);
        }
        static void Main(string[] args)
        {
            Console.WriteLine("Observer Pattern");

            IObserver obs1 = new ObserverType1("Jessie");
            IObserver obs2 = new ObserverType2("Luke");
            IObserver obs3 = new ObserverType1("Bo");

            Subject sbj = new Subject();

            sbj.Register(obs1);
            sbj.Register(obs2);
            sbj.Register(obs3);

            sbj.Flag = 50;

            sbj.UnRegister(obs1);

            sbj.Flag = 100;
        }