System.InvalidOperationException: Collection was modified

前端 未结 6 1265
花落未央
花落未央 2020-11-30 15:05

I am getting a following exception while enumerating through a queue:

System.InvalidOperationException: Collection was modified; enumeration opera

6条回答
  •  忘掉有多难
    2020-11-30 15:52

    I think I had a similar exception when using a foreach loop on a Collection where I tried to remove items from the Collection (or it may have been a List, I can't remember). I ended up getting around it by using a for loop. Perhaps try something like the following:

    for (int i=0; i

提交回复
热议问题