Saturday, February 19, 2011

.NET Interview Question - How does delegate differ from an event?

.NET Interview Question - How does delegate differ from an event?

Delegate is an abstract strong pointer to a function or method while events are higher level of encapsulation over delegates. Events use delegates internally.

They differ for the below reasons:-

• Actually, events use delegates in bottom. But they add an extra layer on the
delegates, thus forming the publisher and subscriber model.

• As delegates are function to pointers, they can move across any clients. So any of the clients can add or remove events, which can be confusing. But events give the extra protection / encapsulation by adding the layer and making it a publisher and subscriber model.


Click here for more 32 .NET/ASP.NET Interview Questions

No comments: