EventHandler<T>
Requiring (or strongly advising, for the sake of consistency) developers to create their own EventArgs
derived type is enough of a burden for them, but in the early days of .NET even that wasn’t enough. One had to create a custom EventHandler
delegate with the typical sender plus event arguments signature:
public delegate void TickEventHandler(object sender, TickEventArgs e)
Since the advent of .NET 2.0, with the introduction of generics, this was simplified a bit through the introduction of EventHandler<T>
:
public delegate void EventHandler<TEventArgs>(object sender, TEventArgs e) where TEventArgs : EventArgs
The generic constraint on the TEventArgs
type argument has been removed in .NET Framework ...
Get C# 5.0 Unleashed 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.