Alex Rivera | Logout

Are non-generic collections in .NET obsolete?

Asked 2008-09-11T12:05:59.850
26

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.

Edit
Report

1 Answer

7

With regard to using non-generic collections for storing heterogeneous collections of stuff, you can always use List<object> to accomplish the same thing. For this reason alone, I'd say there's almost no reason at all to touch the non-generic collections ever again.

The exception to this would be to maintain compatibility with systems written in other languages, or against previous versions of the .NET framework, but that's a pretty "edgy" case if you ask me.

answered 2008-09-11T12:19:07.727

Your Answer