Read and Repeat Aloud:
A
delegate
is a class that can hold a reference to a method. Unlike other classes, a
delegate
class has a signature, and it can hold references only to methods that match its signature. A
delegate
is thus equivalent to a type-safe function pointer or a callback. While
delegate
s have other uses, the discussion here focuses on the
event handling
functionality of
delegate
s...
An
event
is a message sent by an object to signal the occurrence of an action. The action could be caused by user interaction, such as a mouse click, or it could be triggered by some other program logic. The object that raises (triggers) the event is called the
event
sender. The object that captures the event and responds to it is called the
event
receiver.
More information:
http://msdn.microsoft.com/en-us/library/17sde2xt(v=vs.71).aspx[
^]
What are the differences between delegates and events?
An
event
declaration adds a layer of abstraction and protection on the
delegate
instance. This protection prevents clients of the
delegate
from resetting the
delegate
and its invocation list and only allows adding or removing targets from the invocation list.
http://stackoverflow.com/questions/29155/what-are-the-differences-between-delegates-and-events[
^]
And More?
A
delegate
in C# is similar to a function pointer in C or C++. Using a
delegate
allows the programmer to encapsulate a reference to a method inside a
delegate
object. The
delegate
object can then be passed to code which can call the referenced method, without having to know at compile time which method will be invoked.
http://www.akadia.com/services/dotnet_delegates_and_events.html[
^]
I hope it's your last question about this subject! ;)