Put differently:
Is there a good reason to choose a loosely-typed collection over a type-safe one (HashTable vs. Dictionary)? Are they still there only for compatibility?
As far as I understand, generic collections not only are type-safe, but their performance is better.
Here's a comprehensive article on the topic: An Extensive Examination of Data Structures Using C# 2.0.
Non-generic collections hold elements of different datatypes. The following are the non-generic collections: ArrayList, BitArray. ArrayList − It represents ordered collection of an object that can be indexed individually. ArrayList is an alternative to an array.
Examples of Collections are IEnumerable, ICollection, ArrayList, HashTable, Stack, Queue etc. Generics are similar to collections, but implemented using Type parameters. Generic collections accept a type parameter and accept the elements of only those type for which the generic collection is instantiated.
A generic collection is strongly typed (you can store one type of objects into it) so that we can eliminate runtime type mismatches, it improves the performance by avoiding boxing and unboxing.
A Generic collection is a class that provides type safety without having to derive from a base collection type and implement type-specific members. A Non-generic collection is a specialized class for data storage and retrieval that provides support for stacks, queues, lists and hashtables.
The non-generic collections are so obsolete that they've been removed from the CoreCLR used in Silverlight and Live Mesh.
There are also issues with COM visibility - COM interop can't be used with generics
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With