design-patterns/Observer/Program.cs

17 lines
369 B
C#
Raw Normal View History

2023-09-04 09:56:02 +00:00

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();