During the iteration process, I need to delete some rows.
foreach (DataRow dtRow in dtTable.Rows)
{
\\some code
for(int i = dt.Rows.Count-1; i >= 0; i--)
{
DataRow dr = dt.Rows[i];
if (dr["Column1"].ToString().Contains("some text"))
dr.Delete();
}
dt.AcceptChanges();
\\some code 2
}
When the code reaches "some code 2" block, I get the error: "For Each Row: The collection has been changed, perhaps the enumeration operation will not be performed."
Can I update a table instance without exiting the current for each loop and starting a new one?
Thank you.