Hi friends,
I want to know that what's the difference between collection and generic collection? Please explain in the programming scenario?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Feb 8, 2012, 11:34 AM
This means that, when retrieving elements of the collection, you have to cast them to their actual type before you can use them as such.
It also means that when you store value types (int, double, char, bool etc) they have to be boxed on the heap when storing them and unboxed (by casting) when you retrieve them, which is a relatively slow process.
In contrast the generic collection classes in the System.Collections.Generic namespace are strongly typed which implies that they store everything internally as its actual type. List
This means that no casting is required when retrieving elements from generic collections and no boxing is required for value types which makes them more performant in that respect.