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
 

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