LIST<> AddRange throwing ArgumentException

后端 未结 2 1597
伪装坚强ぢ
伪装坚强ぢ 2021-02-14 18:33

I have a particular method that is occasionally crashing with an ArgumentException:

Destination array was not long enough. Check destIndex and length, and the ar         


        
相关标签:
2条回答
  • 2021-02-14 18:52

    Are you trying to update the same list from multiple threads? That could cause problems... List<T> isn't safe for multiple writers.

    0 讨论(0)
  • 2021-02-14 18:53

    Honestly, I'm not sure, but why not just remove the size declaration on your List initialization?

    List`<MyType>` list = new List`<MyType>`
    
    0 讨论(0)
提交回复
热议问题