C# preventing Collection Was Modified exception

前端 未结 10 1778
梦毁少年i
梦毁少年i 2021-01-17 17:16

Does

 foreach(T value in new List(oldList) )

is dangerous (costly) when oldList contains 1 millions of object T ?

More g

10条回答
  •  悲&欢浪女
    2021-01-17 17:58

    You could iterate through the list without using an enumerator, so do something like...

    for(int i = 0;i

提交回复
热议问题