check if dictionary has entry c# code example
Example 1: c# check to see if dictionary key exists
bool keyExists = dict.ContainsKey(key);
Example 2: if in dictionary c#
if (dict.ContainsKey(key)) { ... }
//or
dict.TryGetValue(key, out value);
bool keyExists = dict.ContainsKey(key);
if (dict.ContainsKey(key)) { ... }
//or
dict.TryGetValue(key, out value);