473,568 Members | 2,905 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Retrieving StringDictionar y key by value

Hi,
I have a StringDictionar y 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.

Nov 15 '05 #1
1 3015
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

"Srikanth" <br**@nospam.br yn.com.au> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
Hi,
I have a StringDictionar y 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.

Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
9889
by: J.R | last post by:
I'm getting an error when I attempt to serialize a type StringDictionary, error suggests type not marked for Serialization, could someone tell me how to go about this? Thanks.
6
7491
by: John | last post by:
Hi! I have a StringDictionary itialized as follows: private void frmICUCalculations_Activated(object sender, System.EventArgs e) { StringDictionary dataDict = new StringDictionary(); dataDict.Add("Item1", "2001" ); dataDict.Add( "Item2", "2002" ); dataDict.Add( "Item3", "2003" ); }
4
3702
by: Sanjay Vyas | last post by:
Sorry, forgot to cross post this one.. This is rather unusual as we would expect any Collection class to implement ICollection interface and furthermore a Dictionary class should implement IDictionary interface. The StringDictionary class does implements all the methods of ICollection and IDictionary yet it does not list these interfaces....
2
4114
by: Wamiq Ansari | last post by:
Hi!, I am trying to add a value to a StringDictionary using its Item Property in C#. However this throws an expection as follows: Cannot implicitly convert type 'Component.TemplateComponent' to 'string'. The method I am using is as follows: private StringDictionary componentList = new StringDictionary(); public void...
2
1318
by: rajmgopal | last post by:
Hi I am using a StringDictionary to store and pass a few string values retrieved from sql server database. I am using these values as inputs to several stored procedures After processing a few 100 or 1000 records , I get an error saying that one of the stored procedure parameter is expecting a value (which I assign from StringDictionary)...
0
1669
by: Simon Dahlbacka | last post by:
I was trying to use the built in settings management and added a User-scoped setting of type System.Collections.Specialized.StringDictionary I run my application, updated the Settings, did Settings.Default.Save() and when started the app again I noticed the new settings did not work! Looking in the created user.config, the...
0
1449
by: Hans | last post by:
Hello, I was trying to use the built in settings management and added a User-scoped setting of type System.Collections.Specialized.StringDictionary I run my application, updated the Settings, did Settings.Default.Save() and when started the app again I noticed the new settings did not work!
4
10669
by: Peter K | last post by:
Hi are there any benefits in using StringDictionary over Dictionary<string, string? It appears they achieve the same thing... (I could be wrong of course). thanks, Peter
5
1966
by: Sanjay Pais | last post by:
I have a table with over 1.3 million rows. I am retrieving only 20 at a time using the with - over clauses In query analyser, the data is retrieved in under a second. When retrieving using the data adaptor.fill or datareader to retrieve the data it takes over 24 seconds. public System.Data.SqlClient.SqlDataReader List1(int PageIndex, int...
0
7693
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7605
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7917
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8118
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7665
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7962
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5217
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.