Shortly after Beta 1 of .NET was released, Microsoft .NET developers realized that prolific use of delegates could easily lead to type-bloat; since each declared delegate in C# created a new type in the system, a large number of delegates would lead to a huge number of types to load, verify, and initialize. In Beta 2, Microsoft introduced an idiom that, it’s hoped, will keep type-bloat down to reasonable levels in .NET.
Microsoft defines two types,
delegate type) and
EventArgs, a glorified C
EventHandler is declared to expect two
parameters: an object reference indicating the
sender of the event,
event data parameter (the
EventArgs or some
This delegate represents the base type for .NET event handlers.
(In Beta 2 and later, all .NET Framework Class Library types with declared events use this
same idiom, so as to remain consistent.) Its
arguments include a
sender parameter, which
refers to the object that issued the event and an
e parameter, which contains additional
event data. Events that do not require additional information
EventHandler delegate directly.
Events that need to send additional information derive their own
custom delegate from this type.
Custom event delegates look similar, except that they replace the
EventArgs parameter with
a custom object derived from
This object contains additional properties or methods that
are specific to the event.
public delegate void ...