LIST<> AddRange throwing ArgumentException

后端 未结 2 1144
我寻月下人不归
我寻月下人不归 2021-02-14 18:34

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:53

    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:57

    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)
提交回复
热议问题