Click here to Skip to main content
15,920,596 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
what is Difference between Dictionary AND Araaylist in C#?
which is better?
Posted
Comments
Sergey Alexandrovich Kryukov 30-Apr-12 12:46pm    
Reason for my vote of 1
Invalid question.
Such questions cannot be valid. If OP cannot see it, it's a big problem in general learning.
--SA

1 solution

You can get more information in books and articles.
These references
http://stackoverflow.com/questions/128636/net-data-structures-arraylist-list-hashtable-dictionary-sortedlist-sorted[^]
http://msdn.microsoft.com/en-us/library/xfhwa508.aspx[^]
http://msdn.microsoft.com/en-us/library/6sh2ey19.aspx[^]
may be helpful.

But, to say what I understood about these in simple terms
1. Dictionary stores the KeyValue pairs. It is a generic collection class, which means there is Type safety. Generic types are particularly efficient in case of value types as they avoid boxing and unboxing. The corresponding non generic collection class is HashTable.

2. ArrayList is a non generic collection class to store items. The corresponding generic collection class is List<t> which is preferable for the same reason mentioned above.

If the values are required to be accessed through their keys then Dictionary<KEY, VALUE>collection class is suitable. Where only items are required to be stored without any need to associate each item with a corresponding key then List<T> is suitable.
 
Share this answer
 
v3
Comments
Sergey Alexandrovich Kryukov 30-Apr-12 12:48pm    
I only fixed formatting; major part mangling was because you failed to escape <>
--SA
VJ Reddy 30-Apr-12 12:52pm    
Thank you, SA.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900