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

Rule:  9@112

Synopsis:Prevent passing null values for sender/object to event handler (for instance-based events)
Language:C#
Severity Level:4
Category:Delegates and events


Description:
9@104 states "Use the sender/arguments signature for event handlers". This is very good, but if you use that, there are some additional rules you should obey:
  • Do not pass null as the event sender parameter when raising a non-static event.
    (Static events do NOT have an (object) instance and thus NO sender.
  • Do not pass null as the event data parameter when raising an event.
    Use EventArgs.Empty when no relevant data can/should be sent with the event.
These two come from MSDN (see http://msdn.microsoft.com/en-us/library/ms229011.aspx).