Oct 27, 2015

What is the difference between HashTable and ArrayList?

1) HashTable is a collection of objects which store values based on key where as ArrayList is just a collection of objects stored based on index 

2) Retrieving value from HashTable is faster as it is linked with key whereas it is difficult in case of ArrayList value is fetched with index 

3) HastTable is used for maintaining huge data


An ArrayList is a dynamic array that grows as new items are added that go beyond the current capacity of the list. Items in ArrayList are accessed by index, much like an array. The Hashtable data structure is typically an array but instead of accessing via an index, you access via a key field which maps to a location in the hashtable by calling the key object's GetHashCode() method. In general, ArrayList and Hashtable are discouraged in .NET 2.0 and above in favor of List and Dictionary which are much better generic versions that perform better and don't have boxing costs for value types

No comments:

Post a Comment