G
Guest
Hello,
I am using Hashtable class in my application to store key/value pairs. It
works great except the types returned are all objects. As a result, there are
type-casts everywhere making the code very hard to read. I believe it should
be relatively easy to derive a class from Hashtable that returns appropriate
types for my application. I started writing it like this
public class PeerTable : Hashtable {
public new PeerTable Clone() {
return (PeerTable)base.Clone();
}
}
But I don't know
1. How to make it return "MyValueType" type when I use something like
myPeerTable[key].
2. How to set dictionaryentry.Key to "MyKeyType" and dictionaryentry.Value
to "MyValueType".
I appreciate your help.
Regards,
Vinay Agarwal
I am using Hashtable class in my application to store key/value pairs. It
works great except the types returned are all objects. As a result, there are
type-casts everywhere making the code very hard to read. I believe it should
be relatively easy to derive a class from Hashtable that returns appropriate
types for my application. I started writing it like this
public class PeerTable : Hashtable {
public new PeerTable Clone() {
return (PeerTable)base.Clone();
}
}
But I don't know
1. How to make it return "MyValueType" type when I use something like
myPeerTable[key].
2. How to set dictionaryentry.Key to "MyKeyType" and dictionaryentry.Value
to "MyValueType".
I appreciate your help.
Regards,
Vinay Agarwal