design-patterns/Observer/Program.cs
2023-09-04 10:56:02 +01:00

16 lines
369 B
C#

var publisher = new Publisher();
var subscriberA = new Subscriber("Alex");
publisher.Subscribe(subscriberA);
var subscriberB = new Subscriber("Bob");
publisher.Subscribe(subscriberB);
publisher.PublishNewsletter();
publisher.PublishNewsletter();
publisher.PublishNewsletter();
publisher.Unsubscribe(subscriberB);
publisher.PublishNewsletter();