Retrieving StringDictionary key by value

  • Thread starter Thread starter Srikanth
  • Start date Start date
S

Srikanth

Hi,
I have a StringDictionary object with Key and Value pairs. I have a
situation where
1. I have to retrieve the Value for a given Key and
2. I have to retrieve the Key for a given Value.

Iam able to do the first requirement (As there is a provision to do that in
the class library) but the problem is with the second requirement.

Does anyone know how to retrieve the Key for a given value?.

Thanks in advance,
Regards,
Srikanth.
 
Think of what you are asking. As an example think of the following example:

Key Value
Red Color
Blue Color
Inch Length
Foot Length

Now you can find easily that Inch is a Length, but if you were to ask for
Length then what would be returned. Remember that all classes are designed
to handle the general cases, if you want a specific you can create a new
class that inherits the base.

What you can do if there is are no duplicates in the Value is iterate
through the items and find the Key from the value.

Lloyd Sheen
 
Back
Top