title: Why does the DataTable.Rows.Count not change after deleting rows?
body: <p>In my project I need to delete all records from a DataTable, so I tried this code :</p>
  
  <pre><code>while (DataTable1.Rows.Count &gt; 0)
      DataTable1.Rows[0].Delete();
  </code></pre>
  
  <p>but this is an infinite loop, it seems that after the <code>Delete()</code> statement the <code>Rows.Count</code> does not changes.  </p>
  
  <p>It appears the records are still there but marked for deletion.<br>
  So I change my count to this :  </p>
  
  <pre><code>int count = DataTable1.Select("", "", DataViewRowState.CurrentRows).Count();
  </code></pre>
  
  <p>So now I can change my loop like this</p>
  
  <pre><code>int count = DataTable1.Select("","",DataViewRowState.CurrentRows).Count();
  while (count &gt; 0)
  {
      DataTable1.Rows[0].Delete(); // THIS IS WRONG NOW
      count = DataTable1.Select("","",DataViewRowState.CurrentRows).Count();
  }
  </code></pre>
  
  <p>Now the count does counts down as expected, but now I have a problem with the <code>Rows[0].Delete()</code> statement.  </p>
  
  <p>It will delete the same row over and over again.  </p>
  
  <p>So my question is, how can I find the first row that is not deleted, and delete it ?<br>
  In other words, the line that is commented with // THIS IS WRONG NOW what can I use at that line ?  </p>
  
  <p>Or is there a better way to do this ?  I tried DataTable1.Clear() but that does not generates delete statements when doing <code>adapter.Update(DataTable1);</code></p>