title: Limit the type of a base class parameter
body: <p>I have a code like this:</p>
  
  <pre><code>public static void ToUpperCase(params Control[] controls)
  {
      foreach (Control oControl in controls)
      {
          if (oControl is TextBox)
          {
              oControl.TextChanged += (sndr, evnt) =&gt;
              {
                  TextBox txtControl = sndr as TextBox;
                  int pos = txtControl.SelectionStart;
                  txtControl.Text = txtControl.Text.ToUpper();
                  txtControl.SelectionStart = pos;
              };
          }
          else if (oControl is ComboBox)
          {
              oControl.TextChanged += (sndr, evnt) =&gt;
              {
                  ComboBox cmbControl = sndr as ComboBox;
                  int pos = cmbControl.SelectionStart;
                  cmbControl.Text = cmbControl.Text.ToUpper();
                  cmbControl.SelectionStart = pos;
              };
          }
          else throw new NotImplementedException(oControl.GetType().DeclaringType.ToString() + " is not allowed.");
      }
  }
  </code></pre>
  
  <p>I want to limit the <code>params Control[] controls</code> to accept only a <code>TextBox</code> and a <code>ComboBox</code> type.</p>
  
  <p>My code is in C#, framework 4, build in VS2010Pro, the project is in WinForms.</p>
  
  <p>Please help. Thanks in advance.</p>