DBC User,
Yes, this is correct. You are not allowed to modify elements of an
enumeration while enumerating through them.
To get around this, use a for loop, and use the indexer on the
collection exposed by the Rows property.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
(E-Mail Removed)
"DBC User" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I would like to delete a row from a dataset based on a condition. Here
> is what I am doing
>
> foreach(row in table1)
> {
> string key = row[columnname];
> foreach(row1 in table2)
> {
> if (row1[columnname].tostring().equals(key))
> row1.delete();
> }
> }
>
> [I made it simple and please ignore the syntax, I have to code
> correct]. right adter I do row1.delete on the next foreach loop of
> table2, the program throws an exception saying the collection is
> changed. How can I delete a row in table2 based on values from table1?
>
> Thanks in advance.
>