title: In a C# event handler, why must the "sender" parameter be an object?
body: <p>According to <a href="https://msdn.microsoft.com/en-us/library/h0eyck3s%28VS.71%29.aspx" rel="noreferrer">Microsoft event naming guidelines</a>, the <code>sender</code> parameter in a C# event handler "is <em>always</em> of type object, even if it is possible to use a more specific type".</p>
  
  <p>This leads to lots of event handling code like:</p>
  
  <pre><code>RepeaterItem item = sender as RepeaterItem;
  if (item != null) { /* Do some stuff */ }
  </code></pre>
  
  <p>Why does the convention advise against declaring an event handler with a more specific type?</p>
  
  <pre><code>MyType
  {
      public event MyEventHander MyEvent;
  }
  
  ...
  
  delegate void MyEventHander(MyType sender, MyEventArgs e);
  </code></pre>
  
  <p>Am I missing a gotcha?</p>
  
  <p><sub>
  For posterity: I agree with the general sentiment in the answers that the convention <em>is</em> to use object (and to pass data via the <code>EventArgs</code>) even when it is possible to use a more specific type, and in real-world programming it <em>is</em> important to follow the convention.</sub></p>
  
  <p>Edit: bait for search: RSPEC-3906 rule "Event Handlers should have the correct signature"</p>