out value?
-
// When a program often has to try keys that turn out not to // be in the dictionary, TryGetValue can be a more efficient // way to retrieve values. string value = ""; if (openWith.TryGetValue("tif", out value)) {Console.WriteLine("For key = \"tif\", value = {0}.", value);} else {Console.WriteLine("Key = \"tif\" is not found.");} What is value? value of the dictionary i.e. in this case openWith.value?
-
// When a program often has to try keys that turn out not to // be in the dictionary, TryGetValue can be a more efficient // way to retrieve values. string value = ""; if (openWith.TryGetValue("tif", out value)) {Console.WriteLine("For key = \"tif\", value = {0}.", value);} else {Console.WriteLine("Key = \"tif\" is not found.");} What is value? value of the dictionary i.e. in this case openWith.value?
This method has to return two things: a boolean indicating if the key is valid and the value associated with a key. You know that a function can only return one thing. So it uses an out parameter to return the value. So the
TryGetValue
method returns true if the key exists or false if the key does not exist. If the key exists, then the variablevalue
will be set to the string associated with that key.