Friday, February 20, 2009

Difference between C# delegates vs Events

Nice post by Julien Couvreur's on the difference between delegates vs events.

In a nutshell, the article summarizes the main differences between delegates vs events.

1. Events can be used inside an interface while a delegate cannot be.
2. Event can be invoked only from within the class in which it has been declared, while a delegate can be invoked even from the class that is creating the object.
3. Event has a pair of customizable accessors (add and remove)
4. Event signature can only be type foo(object source, EventArgs e)