Dictionary vs ArrayList
2 answers
You shouldn't actually use ArrayList
, as you are using strongly typed List<T>
.
What you use depends on how you need to access the data. A list stores a sequential list of items, while a dictionary stores items identified by a key. (You can still read items from the Dictionary sequentially, but the order is not preserved.)
The performance is almost the same as the internal arrays for storing actual data. When they reach their capacity, they allocate a new larger array and copy the data to it. If you know how big the collection is, you must specify the capacity when you create it so that it doesn't change on its own.
+3
a source to share