TICS Coding Standard Viewer 
TIOBE Software Quality Framework
Print-friendly version
©TIOBE Software www.tiobe.com
 
C# Coding Standard
Search

Rule:  9@111

Synopsis:Use generic event handler instances
Language:C#
Severity Level:5
Category:Delegates and events


Description:

See http://msdn.microsoft.com/en-us/library/ms182178.aspx for a complete description and example of this FxCop based rule (CA1003).

Before .NET Framework 2.0, in order to pass custom information to the event handler, a new delegate had to be declared that specified a class that was derived from the System.EventArgs class.
This is no longer true in .NET Framework 2.0, which introduced the System.EventHandler(Of TEventArgs) delegate.

This generic delegate allows any class that is derived from EventArgs to be used together with the event handler.
A static generic EventHandler will supply a null sender object (there's no object instance !).
An instance EventHandler will supply the object instance that raises the event as sender.