2
Reply

What is the difference between Delegates and Event? i have some idea but it is not very clear to me.Please help...

Nitin Singhal

Nitin Singhal

Dec 05, 2007
5.2k
0

    First Defination
    Delegate is a class that can hold a reference to a method or a function.
    Event works with source and listener methodology. So, listeners who are interested in receiving some events they subscribe to the source. Once the subscription is done the source rises events to its entire listener when needed.

    Now Difference
    1. Actually, events use delegates in bottom. But they add an extra layer on the delegates. thus forming the publisher and subscriber model.
    2. As delegates are function to pointers they can model across any clients. So any of the clients can add or remove events, which can be pretty confusing. But event give the extra protection by adding the layer and making it a publisher and subscriber model.

    More important .NET Questions & Answer

    Elias Hossain
    February 23, 2008
    0

    Delegates are reference types which is used to encapsulate a method with specific signature. These are used to call back functions and asynchronous calls to the requests. These are much like function pointers in c. Events are nothing but methods which are using to rise the methods when control is fired.

    chaitanya k
    December 20, 2007
    0