Data structures in .NET

In table below official recommendations for choosing data structure for your needs:

GenericNon-GenericThread safePurpose
DictionaryHashtableConcurrentDictionarykey value pairs, lookup
ListArrayImmutableListaccess items by index
QueueConcurrentQueueFIFO queue
StackConcurrentStackLIFO queue
LinkedListaccess items sequentially
ObservableCollectionnotfications after modification
SortedListImmutableSortedSetauto sorted collection
HashSetImmutableHashSetdictionary of just keys (high performance set operations)

Further read:

https://learn.microsoft.com/en-us/dotnet/standard/collections/

Leave a Reply

Your email address will not be published. Required fields are marked *

Solve : *
6 + 20 =