title: Delete controls based on their Class
body: <p>I need to delete some controls in TableLayoutPanel. The code below works well for Buttons:</p>
  
  <pre><code>private void RemoveButtons()
  {
      for (int i = TablePanel.Controls.Count - 1; i &gt;= 0; i--)
      {
          if (TablePanel.Controls[i] is Button)
              TablePanel.Controls[i].Dispose();
      }
  }
  </code></pre>
  
  <p>But, in other situations I need to delete Panel, User controls, etc. How to change the code above to delete controls based on the Class of controls in one method?</p>
  
  <pre><code>private void RemoveControls(Type class)
  {
      for (int i = TablePanel.Controls.Count - 1; i &gt;= 0; i--)
      {
          if (TablePanel.Controls[i] is class)
              TablePanel.Controls[i].Dispose();
      }
  }
  </code></pre>