I don't think there's anything wrong with what you want to do. For the most part, I suspect that the object sender
parameter remains in order to continue to support pre 2.0 code.
If you really want to make this change for a public API, you might want to consider creating your own base EvenArgs class. Something like this:
public class DataEventArgs<TSender, TData> : EventArgs
{
private readonly TSender sender, TData data;
public DataEventArgs(TSender sender, TData data)
{
this.sender = sender;
this.data = data;
}
public TSender Sender { get { return sender; } }
public TData Data { get { return data; } }
}
Then you can declare your events like this
public event EventHandler<DataEventArgs<MyClass, int>> SomeIndexSelected;
And methods like this:
private void HandleSomething(object sender, EventArgs e)
will still be able to subscribe.
EDIT
That last line made me think a bit... You should actually be able to implement what you propose without breaking any outside functionality since the runtime has no problem downcasting parameters. I would still lean toward the DataEventArgs
solution (personally). I would do so, however knowing that it is redundant, since the sender is stored in the first parameter and as a property of the event args.
One benefit of sticking with the DataEventArgs
is that you can chain events, changing the sender (to represent the last sender) while the EventArgs retains the original sender.