While working on the Download class of the .Net Download Library yesterday, I came across the need to add and retrieve items from a HashTable of a fixed type. After asking at MSDN forums, someone suggested creating for example a StringHashTable, which then contains a number of Shadow methods that ctype a parameter of the type String to Object, and then pass it along to the corresponding native method of the base class. I extended a little on this by creating a general type defined HashTable extension class: TypeHashTable. This class is pretty identical to the String variant, but I added one variable type (see the code below), making it usable for whatever type you need it, without any manual converting. I’m probably not implementing this in the .Net Download library, since the conversion there only requires a one line function, and the philosophy is to keep it as simple and small as possible. Anyway, I’ve put this class on my forums so that anyone can use it. It’s also a neat example of the usage of variable type definitions IMHO

Categories
Tag Cloud
Blog RSS
Comments RSS
Last 50 Posts
Back
Void « Default
Life
Earth
Wind
Water
Fire
Light 