I am using the code below to loop through the rows of a datatable. If a certain condition is met I then delete the row from the datatable.
This then causes a "System.InvalidOperationException: 'Collection was modified; enumeration operation might not execute.'" error.
What is the proper way to do this, so that the loop processes all rows? Thanks.
Code:For Each row As DataRow In DT.Rows 'do some stuff here If someCondition = True Then DT.Rows.Remove(row) End If Next




Reply With Quote
