Get single value from dictionary by key

It really does seem like you’re overcomplicating this issue.

You can just use the indexer ([]) of the Dictionary class along with the .ContainsKey() method.

If you use something like this:

string value;
if (myDict.ContainsKey(key))
{
    value = myDict[key];
}
else
{
    Console.WriteLine("Key Not Present");
    return;
}

You should achieve the effect that you want.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)