The Generic 'event delegate Type (available since .NET 2.0) that uses <T> where 'T
may be a Type that inherits from (whose base class is) EventArgs is used when you need to pass custom data from the context in which the Event is triggered to the "consumers" of the Event who create EventHandlers for the Event and add those EventHandlers to the Invocation List of the Event.
Note that I said "'T may be:" that's not absolutely required: you can get away with using this:
public class MyNewEventArgs
{
public int someX = 199;
MyNewEventArgs(int x = 999)
{
someX = x;
}
}
public event EventHandler<myneweventargs> SomethingHappened;
private void Form1_Load(object sender, EventArgs e)
{
SomethingHappened += Form1_SomethingHappened;
}
public void Form1_SomethingHappened(object sender, Form1.MyNewEventArgs e)
{
Console.WriteLine(e.someX);
}
private void button1_Click(object sender, EventArgs e)
{
SomethingHappened(this, new MyNewEventArgs(1001));
}</myneweventargs>
You could get even more concise equivalents to a generic EventHandler with custom arguments using 'Action and 'Func delegates (they are full-fledged multi-cast creatures), but generally it's always better to stick to the "classic" format of using a custom class that inherits from 'EventArgs: results in more consistent code, easier to maintain code, and code that external "consumers" of your code finds consistent with their expectations.
In a recent answer to another question here [
^] I gave an example of using a Custom EventArgs based class in a generic Event definition.
That example focuses on how to use a generic Event that implements an Interface, but I think you may find some value in looking at that example and at my comments to a question from a member about that example.