I need to return a key from a Hashtable (I presume the same code will work for SortedList)
I know how to return a value, thus:
//this is my hashtable; assume that the values are strings and keys are integers
Hashtable hs = new Hashtable();
//to return a value (say value2) i write
string temp = (string)hs[key2];
How do I return key2 //without using index or looping through the items?
I know I can't write
int temp2 = (int)hs[value2];
The only relevant samples I saw in the VS documentation made use of indexes or loops through the keys. There are 300 or so items in my hashtable, and looping through them each time the user needs just a key doesn't sound efficient to me.
Any help is already being appreciated;)