title: Is disposing a panel equivalent to disposing its children plus itself?
body: <p>Within the following class:</p>
  
  <pre><code>class MyPanel : Panel
  {
      ...
      protected override void Dispose(bool disposing)
      {
          // My code here
      }
  }
  </code></pre>
  
  <p>are the following two code samples equivalent?</p>
  
  <pre><code>base.Dispose(disposing);
  </code></pre>
  
  <p>vs</p>
  
  <pre><code>if (disposing)
  {
      List&lt;Control&gt; ctrls = new List&lt;Control&gt;(this.Controls);
      this.Controls.Clear();  
      foreach(Control c in ctrls)
      {
           c.Dispose();
      }
  }
  base.Dispose(disposing);
  </code></pre>
  
  <p>If they have a different effect, what would it be?</p>
  
  <p><strong>Edit:</strong> I ask this because, for whatever reason, doing it the first way freezes my program before it gets to disposing any of its children (<code>disposing</code> is true, and <code>Controls</code> contains 2 controls), whereas the second way works fine. If I can happily use the second one, then that's great.</p>