Mid Collections

What are some performance trade-offs when choosing between different collections?

Scenario Best Choice Trade-offs

Fast indexed

access

List<T> Slower inserts/removes in

the middle

Frequent

insert/delete at

ends

LinkedList<T> No fast indexed access;

higher memory use

Fast lookups by

key

Dictionary<TKey, TValue> No sorted order

Sorted key-value

pairs

SortedList<TKey, TValue> or

SortedDictionary<TKey,

TValue>

Slower inserts vs

Dictionary

Thread-safe

multi-thread use

ConcurrentDictionary /

ConcurrentQueue

Slight overhead for

synchronization

More from C# Programming Tutorial

All questions for this course