J
Jeff Brown
More than once in the .NET documentation, they say, "By convention, event
delegates in the .NET Framework have two parameters: The source that raised
the event, and the data for the event [which is an instance of the EventArgs
class, or of a class that's derived from EventArgs]."
It seems that this convention results in twice as much work whenever we have
custom arguments for an event handler. Specifically, we must define:
1. A custom data class, which is derived from EventArgs; and
2. (for maximum type safety) A custom event delegate, which takes an
instance of the aforementioned data class as its second argument.
On the other hand, if we DON'T follow the convention, then we can simply
define:
1. A custom event delegate whose arguments are simply the custom data
values, listed directly.
Does anyone know: Is there any TECHNICAL reason that we should follow the
convention? In other words, is there any aspect of the .NET framework that
DEPENDS upon the convention being followed?
Thanks,
Jeff Brown
delegates in the .NET Framework have two parameters: The source that raised
the event, and the data for the event [which is an instance of the EventArgs
class, or of a class that's derived from EventArgs]."
It seems that this convention results in twice as much work whenever we have
custom arguments for an event handler. Specifically, we must define:
1. A custom data class, which is derived from EventArgs; and
2. (for maximum type safety) A custom event delegate, which takes an
instance of the aforementioned data class as its second argument.
On the other hand, if we DON'T follow the convention, then we can simply
define:
1. A custom event delegate whose arguments are simply the custom data
values, listed directly.
Does anyone know: Is there any TECHNICAL reason that we should follow the
convention? In other words, is there any aspect of the .NET framework that
DEPENDS upon the convention being followed?
Thanks,
Jeff Brown