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:

http://geekswithblogs.net/blackrabbitcoder/archive/2011/06/16/c.net-fundamentals-choosing-the-right-collection-class.aspx

while talks generic collecitons in particular, arraylist have similar complexity costs list<t> , hashtable dictionary<tkey, tvalue>


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -