public delegate void Action<object?, EventArgs>(object? sender, EventArgs e);
public delegate void EventHandler(object? sender, EventArgs e);
What is the difference between those two lines? They seem to be functionally equal.
public delegate void Action<object?, EventArgs>(object? sender, EventArgs e);
public delegate void EventHandler(object? sender, EventArgs e);
What is the difference between those two lines? They seem to be functionally equal.
Rotabor's answer is basically correct, except for the reasoning:
EventHandlerexists since .NET Framework 1.1, which did not have generics and thus also did not yet haveAction<T>. Only fully defined delegate types where allowed.When
Action(with it's generic overloads) was added in .NET Framework 2.0,EventHandlerwas kept for backwards compatibility.