大家好, 我有一个dataTable说dt1,现在我想从这个数据表中删除一行,我用dr.delete()和dt.AcceptChanges()方法做同样的事情但是我收到了错误。 我收到了这个错误:= 收藏被修改了;枚举操作可能无法执行。 你能告诉我这个解决方案。 谢谢 Rohit Vyas
Hello all, I have a dataTable say dt1,now i want delete a row from this datatable,i have used dr.delete() and dt.AcceptChanges() methode to do the same but i got error . I got this error:= Collection was modified; enumeration operation might not execute. Can you people tell me the solution of this. Thanks Rohit Vyas
推荐答案大家好, 我有一个dataTable说dt1,现在我想从这个数据表中删除一行,我使用dr.delete()和dt.AcceptChanges()方法做同样的但我得到了错误。 我收到此错误:= 收藏品已被修改;枚举操作可能无法执行。 你能告诉我这个解决方案。 谢谢 Rohit Vyas Hello all, I have a dataTable say dt1,now i want delete a row from this datatable,i have used dr.delete() and dt.AcceptChanges() methode to do the same but i got error . I got this error:= Collection was modified; enumeration operation might not execute. Can you people tell me the solution of this. Thanks Rohit Vyas
这是因为你在迭代它时无法修改实际的集合。如果列表大小很小,请使用ToArray方法并对其进行迭代,否则创建需要删除的所有值的另一个列表,然后在第一次迭代后在单独的循环中执行删除。
That''s because you cannot modify the actual collection while you''re iterating through it. If the list size is small, use the ToArray method and iterate over that, otherwise create another list of all the values that need to be deleted and then do the deletion in a separate loop after the first iteration.
那是因为你在迭代它时不能修改实际的集合。如果列表大小很小,请使用ToArray方法并对其进行迭代,否则创建需要删除的所有值的另一个列表,然后在第一次迭代后在单独的循环中执行删除。 That''s because you cannot modify the actual collection while you''re iterating through it. If the list size is small, use the ToArray method and iterate over that, otherwise create another list of all the values that need to be deleted and then do the deletion in a separate loop after the first iteration.
感谢您的回复 您能告诉我代码吗,我该怎么办...
Thanks for reply Can you show me the code,how can i do it...
感谢您的回复 您能告诉我代码,我该怎么做... Thanks for reply Can you show me the code,how can i do it...
代码基本上取决于您使用什么标准进行删除。 我不喜欢编写代码并热衷于讨厌.NET但是如果按下我会说你需要做一些像
The code basically depends on what criteria you''re using for deleting. I don''t like writing code and hate .NET passionately but if pressed I''d say you need to do something like
展开 | 选择 | Wrap | 行号
更多推荐
从DataTable中删除行
发布评论