title: Error using .RemoveAt to delete a DataTable row in a loop
body: <p>I'm working on a program and don't know how to fix this problem i'm having now.</p>
  
  <p>When i run this code:</p>
  
  <pre><code>int maxRows = AfdelingDT.Rows.Count;
  maxRows -= 1;
  for(int i = 0;i &lt;= maxRows; i++)
  {
     if (Convert.ToInt16(AfdelingDT.Rows[i][0]) == Convert.ToInt16(removeRowTB.Text))
     {
        AfdelingDT.Rows.RemoveAt(i);
     }
  }
  </code></pre>
  
  <p>I'm having a error that the row doesn't exist if I try to delete a row in the middle of the <code>DataTable</code>.</p>
  
  <p>If I run the code for the last row of the table I have no problem at all.</p>