Click here to Skip to main content
15,887,267 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
What is the main advantage of collection and which is the best class in collection
Posted
Updated 19-Dec-11 21:46pm
v2
Comments
lukeer 19-Dec-11 8:38am    
The main advantage of collections is that you can store things in them.

But, seriously, the question is far too vague for a more decent answer. Please use the "Improve question" link and tell us
1. what to compare a collection against
2. for what purpose you are going to use it.

You may find the answers to you questions inside the related documentation, see, for instance "Selecting a Collection Class"[^] or, somethimes, just using common sense: if there were 'the best' collection class then what's the need for the other ones?
 
Share this answer
 
Comments
thatraja 19-Dec-11 15:57pm    
Fine link, 5!
Sergey Alexandrovich Kryukov 19-Dec-11 19:12pm    
I voted 5 for this answer, but there is a bit more to it: I explained why not non-generic non-specialized collection classes should be avoided in favor of the generic ones.

Please see my answer.
--SA
None of the collection generic classes is better than any other. The reason is very simple: if Microsoft considered adding two classes to the library, A and B, and it could be found that class B is better then A, why would they include A? The same would happen to any other software developer not experiencing brain damage. All of those classes are needed for some purposes.

At the same time, I would warn against using any non-generic collection classes, except specialized ones. These classes are rendered obsolete by introduction of generics in .NET Framework v.2.0. However, they should be considered obsolete only for new development, that's why they are not marked formally with System.ObsoleteAttribute; if they work well in a well-tested legacy code, there is nothing wrong with them. However, using them for new development just makes no sense at all: who needs and extra type case without any apparent reason?

—SA
 
Share this answer
 
Comments
thatraja 19-Dec-11 23:02pm    
Point, 5!
Sergey Alexandrovich Kryukov 19-Dec-11 23:52pm    
Thank you, Raja.
--SA
yeshgowda 20-Dec-11 0:00am    
Absolutely r8! My 5points
Sergey Alexandrovich Kryukov 20-Dec-11 0:04am    
Thank you.
--SA
CPallini 20-Dec-11 3:29am    
My 5.

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