title: Cast sender object in event handler using GetType().Name
body: <p>I have an event handler for a Textbox and a RichTextBox.
  The code is identical, but</p>
  <p>In handler #1 I do:</p>
  <pre><code>RichTextBox tb = (RichTextBox)sender
  </code></pre>
  <p>In handler #2 accordingly:</p>
  <pre><code>TextBox tb = (TextBox)sender
  </code></pre>
  <p>Doing so I can fully manipulate the sending control.
  How can I cast the sending object to <code>Textbox</code> or <code>RichTextbox</code> according to its type using</p>
  <pre><code>sender.GetType().Name
  </code></pre>
  <p>and then create the control at runtime and work with it? That way I only need one event handler function: less code, less errors, easier to maintain and DRY :-)</p>