Parameters

ParameterDescription
senderThe object that raised the event.
eA System.EventArgs instance that contains the event data.

BG Note that we have to define delegates that are similar to EventHandler for every unique type of event, each consuming its own subclass of EventArgs. Here is a very common design pattern that could theoretically benefit from generics. Instead of defining a custom event handler for every type of event we could define this:

public delegate void EventHandler<T>(Object sender, T args) where
 T : EventArgs

Then events might use syntax similar to the following:

 public event EventHandler<MouseEventArgs> MouseMoveEvent; ...

Get .NET Framework Standard Library Annotated Reference, Volume 1: Base Class Library and Extended Numerics Library now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.