static void Main(string[] args) { var collection = new CollectionNumber(); collection.Subscribe(new Listener()); collection.Add(5); collection.Add(1); collection.Add(3); collection.Subscribe(new Listener()); collection.Add(0); collection.Delete(1); foreach (var item in collection) { Console.WriteLine(item); } Console.ReadLine(); }
public Unsubscriber(CollectionNumber sensor, IObserver <CollectionNumber> listener) { _sensor = sensor; _listener = listener; }