Difference between event and delegate?

 Posted by Ddd on 2/21/2011 | Category: .NET Framework Interview questions | Views: 17203 | Points: 40


1) It is a data member of a type(class/structure)

2)It is declared inside a type(class/structure)

3) It is used to generate notifications which are then passed to methods though


1)It is a datatype(reference type) that holds references of methods with
some signatures.also called as function pointer.

2)It may or may not be declared inside a class.

3)It is used as the return type of an event and used in passing messages from event to methods.

namespace dd
//delegate declaration
delegate void first();
class cc
//event declaration
public first myevent;

example 2:
button1.Click+=new EventHandler(this.button1_Click);
(Windows Applications)

Click is the event that returns an instance of the EventHandler delegate.
EventHandler delegate has the reference of button1_Click event and that
helps in the communication betwen the Click event and button1_Click method

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response