Often overlooked specialized collections

The lost treasures of .net class library, part I: The System.Collections.Specialized namespace has a few excellent classes that can help you (at least until you get generics, that is). Too bad many coders have never even heard of them. Here's a short introduction:
HybridDictionary and ListDictionary are just perf-tweaked Hashtable implementations. Fine, but not earth-shattering. But it gets better: StringCollection is essentially an typed arraylist, or an flexible-size string array, if you will. StringDictionary is an Hashtable with the key strongly typed as a string. NameValueCollection is excellent for configurations and some other situations (by the way, it's actually used for this purpose by .net).
For some do-it-yourself-spirit, there's also NameObjectCollectionBase, a base class for your own string-keyed typed Hashtables. See the help for an example. And last but not least, CollectionsUtil with static method shortcuts for creating case-insensitive SortedLists and Hashtables.

November 4, 2004 В· Jouni Heikniemi В· One Comment
Posted in: .NET

One Response

  1. RCIGWHHLDUKPWD - August 29, 2018

    I do agree with all of the ideas you've presented in your post. They're really convincing and will certainly work. Still, the posts are very short for beginners. Could you please extend them a bit from next time? Thanks for the post.

Leave a Reply