What is the difference b/t Arrays and hash List?
Which one is faster?
Array Vs Hash List
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Pradeep ShetRank #595 · 4K reputationPosted Oct 16, 2014, 1:16 AM EDT
ArrayList works on indexing whereas HashTable works on Key.
In case of ArrayList, when you ask for any index it will iterate through the list and then fetch the desired index whereas for HashTable it will directly fetch the value based on the key.
Hope this helps you. If it is so plz mark it as answered.
Munesh SharmaRank #174 · 13.9K reputationPosted Oct 16, 2014, 2:42 AM EDT
An
ArrayListis 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
Hashtableis a hashtable behind the scenes. The underlying 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'sGetHashCode()method.In general,
ArrayListandHashtableare discouraged in .NET 2.0 and above in favor ofListandDictionarywhich are much better generic versions that perform better and don't have boxing costs for value types.http://dotnet-munesh.blogspot.in/2013/12/difference.html
Munesh SharmaRank #174 · 13.9K reputationPosted Oct 16, 2014, 2:43 AM EDT