How are items stored in containers in .Net?

How are items stored in containers in .Net? For example, a C ++ vector is stored in sequential order, while a List is not.
How are they implemented for .Net containers (Array, ArrayList, ...)?
Thank.

+3
source share
3 answers

It depends on the item. But C ++ is Vectorequivalent to C # List, and C ++ is List<T>equivalent to C # LinkedList

C # ArrayListpretty much C #List<object>

Wikipedia lists many data structures , and I suggest you look there to see how different are implemented.

So:

C++        C#                      How
Vector     ArrayList / List        Array (sequential)
List       LinkedList              Linked List (non-sequential, i.e. linked)
+1

. , , , .

, , , , MS :

  • Microsoft.NET Framework.
  • .
+1

.net ( ) . ( , , , ), , . , , - "", , - .

Recently, I heard that arrays store their records sequentially - with the caveat that for objects of a reference type (everything that is not a structure), "records" are links, not the objects themselves. Data can be anywhere in memory. Think of it more as an array of links than an array of objects.

ArrayLists, based on arrays, should store their things the same way.

+1
source

Source: https://habr.com/ru/post/1757278/


All Articles