How is List <T> internally displayed?

Is it internally processed as an array, or is it processed by the CLR as a completely different type?

I am trying to implement integer values ​​in a list.

List<int> lst = new List<int>();
lst.Add(3);
lst.Add(4);

against.

I create an array of integers

int[] arr = new int[2];
arr[0] = 3;
arr[1] = 4;

The array returns the best time intervals. So why do people prefer List <>.

+5
source share
2 answers

List<>represents an implementation of a data structure that takes care of memory allocation on demand; it allows you to insert and delete at any index, etc. Therefore, it is much more convenient than a simple array.

List<> , . ( ) . , , , ( , Length ).

+5

. .NET List<T> . , LinkedList<T>, . .

List<T> (4, ), max- , . ( ), , .. 5- 8 ..

+1

All Articles