xxxxxxxxxx
string value = "";
if (openWith.TryGetValue("tif", out value))
{
Console.WriteLine("For key = \"tif\", value = {0}.", value);
}
else
{
Console.WriteLine("Key = \"tif\" is not found.");
}
xxxxxxxxxx
Dictionary<string, int> dictionary = new Dictionary<string, int>() {
{ "apple", 5 },
{ "banana", 8 },
{ "orange", 3 }
};
int value;
if (dictionary.TryGetValue("banana", out value))
{
// Key was found, and value is assigned to 'value'
Console.WriteLine($"Value of 'banana': {value}");
}
else
{
// Key was not found
Console.WriteLine("Key not found");
}