How and when to abandon the use of arrays in C#?

后端 未结 15 1708
盖世英雄少女心
盖世英雄少女心 2020-12-13 02:58

I\'ve always been told that adding an element to an array happens like this:

An empty copy of the array+1element is created and then the data from t

15条回答
  •  眼角桃花
    2020-12-13 03:33

    If you are going to be doing a lot of adding, and you will not be doing random access (such as myArray[i]). You could consider using a linked list (LinkedList), because it will never have to "grow" like the List implementation. Keep in mind, though, that you can only really access items in a LinkedList implementation using the IEnumerable interface.

提交回复
热议问题