Hi Dudes
Can any one help me that what is difference b/w Generic Collections and Non-Generic Collection and alo
Generic Collections vs Non-Generic Collection
2 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
VulpesRank #55 · 29.2K reputationPosted Jun 26, 2011, 11:39 PM EDT
In the .NET Framework, the non-generic collections (ArrayList, Hashtable, SortedKist, Queue etc.) store elements internally in 'object' arrays which, can of course, store any type of data.
This means that, in the case of value types (int, double, bool, char etc), they have to be 'boxed' first and then 'unboxed' when you retrieve them which is quite a slow operation.
Whilst you don't have this problem with reference types, you still have to cast them to their actual types before you can use them.
In contrast, generic collections (List
This means that generic collections are faster than their non-generic counterparts when using value types and more convenient when using reference types. In short, the latter are now virtually redundant.
Sandeep ShekhawatRank #2,439 · 577 reputationPosted Jun 26, 2011, 10:16 PM EDT