Eric,
The overall reason is that it is quite simply the pattern that was
established. While this doesn't sound like the best reason in the world, it
is the way it is, and it makes everything easier because its implementation
is just short of universal.
However, I can say that there is one benefit to this pattern. Because a
method can be registered to handle multiple event notifications, the sender
parameter becomes very, very important. It allows for more reusable code.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"Eric Cadwell" <ec******@ns.insight.com> wrote in message
news:u8**************@TK2MSFTNGP11.phx.gbl...
What advantages do I reap by following the EventArgs pattern in defining
custom event delegates?
For example...
public delegate void CustomEventHandler(object sender, CustomEventArgs e);
public class CustomEventArgs : System.EventArgs
{
int index = 0;
public CustomEventArgs(int Index)
{
index = Index;
}
public int Index
{
get { return index; }
}
}
...instead of simply using...
public delegate void CustomEventHandler(int Index);
It's so much more work. There's a lot of boilerplate in writing events and
controls.
Thanks,
Eric