Delegate (C#) versus Observer Pattern?
I have a question: Is the delegate in C# equivalent to the Observer Pattern? If not, what is the difference?
Thanks in advance.
Asmprogs Asmprogs, Sep 03, 2010
In C# Langaugage, Microsoft has provided the facility of multi-cast delegate to implement the Observer Pattern. As Rajesh has mentioned there are sites which provides the implementation of same.
At the same time there is something you need to be aware off when using the multi-cast delegate. If the user has assigned, say two delegates and then assigns a null value, it will be treated as un-assigned and both previously assigned delegates will not execute.
Saurabh Saxena, Sep 06, 2010
In a way delegates and events can be used to implement observer pattern. You'll find some useful discussions here
Rajesh Pillai, Sep 03, 2010