As the title suggests I would like to know what the difference is between a collection for which I have to set the type of items and all the specialized collections for only one datatype. Does it matter which one I use?
And also is there a difference between List<String>
and Collection<String>
?
String is just an example, I'm asking in general.
Strongly typed string collection is to prevent upcasting or downcasting overhead and optimized for strings.
The reason for providing StringCollection
is to provide better performance. However, I would be surprised if there is a huge performance difference between them.
Consider the following recommendations for using StringCollection: Ref
StringCollection
to store string data that changes frequently and
needs to be retrieved in large chunks.StringCollection
for binding string data to a data grid. This
avoids the cost of downcasting it to a string during retrieval.StringCollection
for sorting strings or to store presorted
data.