c# 3.0 - What is difference between ArrayList and Hashtable in C#? -
i want store collection of data in arraylist or hastable data retrival should efficient , fast. want know data structure hides between arraylist , hastable (i.e linked list,double linked list)
an arraylist
dynamic array grows new items added go beyond current capacity of list. items in arraylist accessed index, array.
the hashtable
hashtable behind scenes. underlying data structure typically array instead of accessing via index, access via key field maps location in hashtable calling key object's gethashcode()
method.
in general, arraylist
, hashtable
discouraged in .net 2.0 , above in favor of list<t>
, dictionary<tkey, tvalue>
better generic versions perform better , don't have boxing costs value types.
i've got blog post compares various benefits of each of generic containers here may useful:
while talks generic collecitons in particular, arraylist
have similar complexity costs list<t>
, hashtable
dictionary<tkey, tvalue>
Comments
Post a Comment