Most efficient way to append arrays in C#?

前端 未结 10 2179
挽巷
挽巷 2020-12-02 19:39

I am pulling data out of an old-school ActiveX in the form of arrays of doubles. I don\'t initially know the final number of samples I will actually retrieve.

What i

10条回答
  •  情话喂你
    2020-12-02 20:06

    You can't append to an actual array - the size of an array is fixed at creation time. Instead, use a List which can grow as it needs to.

    Alternatively, keep a list of arrays, and concatenate them all only when you've grabbed everything.

    See Eric Lippert's blog post on arrays for more detail and insight than I could realistically provide :)

提交回复
热议问题