views:

251

answers:

3

I know the value of key for my Hashtable, from key how can I obtain the object of DictinaryEntry.

I don't want to Iterate over Hashtable.

A: 

I don't know if I'm understanding your question correctly, but couldn't you just use this?

myHashtable[key]
David Hedlund
+3  A: 

Although DictionaryEntry is the type returned when you iterate a Hashtable, it's not really true that a Hashtable 'contains' DictionaryEntrys. DictionaryEntry is a value type and so doesn't have an identity. If you want 'a' DictionaryEntry containing a given key and the matching value, you can make one yourself:

DictionaryEntry de = new DictionaryEntry(key, myHashtable[key]);
AakashM
A: 

I recommend you to use Dictionary instead of Hashtable as it is a typed Hashtable. For data retreivale

         if(myHahtable.ContainsKey(key))
            object value = myHahtable[key];
Ahmed Said
I've bind Hashtable with a ComboBox using BindingSource !
Tumbleweed