Alex Rivera | Logout

When to use a HashTable

Asked 2010-06-17T11:21:57.307
29

In C#, I find myself using a List<T>, IList<T> or IEnumerable<T> 99% of the time. Is there a case when it would be better to use a HashTable (or Dictionary<T,T> in 2.0 and above) over these?

Edit:

As pointed out, what someone would like to do with the collection often dictates what one should be using, so when would you use a Hashtable/Dictonary<T,T> over a List<T>?

c#
Edit
Report

1 Answer

1

Hash-tables are good choices if you are often doing "for something in collection" and you aren't concerned about the order of items in the collection.

Hash-tables are indexes. You can maintain a hash-table to index a list, so you can both choice to access it in order or randomly based upon the key.

answered 2010-06-17T11:25:06.763

Your Answer