Observer Design Pattern in C#

The observer pattern is a Gang of Four design pattern and one of the most interesting patterns in design pattern. this pattern listed under Behavioral Patterns.


Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.This pattern suitable push-based notifications.

you can watch youtube video related observer design pattern’s logic.I recommend this.

and you can find a great technical post via codeproject.In this post you’ll see example blog subscriber with observer pattern.I made three example for this.

1- Classic sample via gist (ObserverDesignPattern.cs)

2 – Sample with event and delegete via gist (ObserverPatternWithEventAndDelegate.cs)

3 – Sample with generic via gist (ObserverPatternWithNetFramework.cs)

you can examine implementation observer pattern with generic structure

have a good codeday 😀

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.