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
Queue–ConcurrentQueueFIFO queue
Stack–ConcurrentStackLIFO queue
LinkedList––access items sequentially
ObservableCollection––notfications after modification
SortedListImmutableSortedSetauto sorted collection
HashSetImmutableHashSetdictionary of just keys (high performance set operations)

Further read:

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

One Reply to “Data structures in .NET”

Leave a Reply

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

Solve : *
24 + 12 =