我在这里所做的是在数组列表和字典中保存两列的表。
Dim result As New ArrayList()
While dr.Read()
' Insert each column into a dictionary
Dim dict As New Dictionary(Of String, Object)
For count As Integer = 0 To (dr.FieldCount - 1)
dict.Add(dr.GetName(count), dr(count))
Next
' Add the dictionary to the ArrayList
result.Add(dict)
End While
.........现在我想检查它,当它找到时 - 删除它。因为有很多数据,所以可以节省时间。我收到错误“集合已修改;枚举操作可能无法执行。” 删除后进入下一步。我理解这个问题,但我该如何克服这个问题?如何将其转换为带删除的循环?
For Each dat As Dictionary(Of String, Object) In result
comp2 = dat("ID")
If comp2 = comp Then
advcode = advcode & "," & dat("ADVC")
found = True
firstattempt = False
result.Remove(dat)
Else
If found And Not firstattempt Then Exit For
End If
Next