-1

Let's say I did the following:

Dictionary<string,NetworkStream> dictionary = new Dictionary<string,NetworkStream>();
dictionary.add("Matt",network);
dictionary.add("Mike",network);
dictionary.add("Jack",network);

How do I pull the Networkstream 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.

NateS
  • 33
  • 6

1 Answers1

1

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

value = dictionary["Jack"];
Sajeetharan
  • 216,225
  • 63
  • 350
  • 396
  • @NateS if you are updating keys with different names, above solution should work – Sajeetharan Nov 24 '16 at 18:26
  • @NateS you are welcome, mark as answer if it had helped – Sajeetharan Nov 24 '16 at 18:32
  • I'm trying but it's telling me: " Thanks for the feedback. Votes cast by those with less than 15 reputation are recorded., But do not change the publicly displayed post score. " – NateS Nov 24 '16 at 18:40