Hashtable

  • Thread starter Thread starter Dave
  • Start date Start date
D

Dave

I know how to get Hashtable value by key, but How can I get Hashtable key by
it's value?
 
You would have to manually search the table for that value.
You could enumerate the table to look for the value, for instance:

Hashtable ht...;
object value...;
IDictionaryEnumerator de = ht.GetEnumerator();
while (de.MoveNext())
{
if (value == de.Value)
Console.WriteLine(de.Key);
}
 
Dave said:
I know how to get Hashtable value by key, but How can I get Hashtable key by
it's value?

You can do it by brute force as Dennis said, but if you're going to
have to do this regularly, you should have two Hashtables - one to map
one way, and the other to map the other way.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top