NateS NateS - 1 year ago 97
C# Question

How to pull the key value based on the key that is inside the Dictionary?

Let's say I did the following:

Dictionary<string,NetworkStream> dictionary = new Dictionary<string,NetworkStream>();

How do I pull the
of Jack? Assuming I have multiple of lines likes this.

UPDATE: I didn't explain myself well, sorry. If the name is already exists I'm not going to add him to the dictionary.. I meant if I have different names.

Answer Source

Dictionary cannot have more than one key with same name, still you can access the value of 'Jack' like this,

value = dictionary["Jack"];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download