Define Dictionary object and add content
Dictionary<string, string> dict = new Dictionary<string, string>() { }; dict.Add("a", "a1"); dict.Add("b", "b1"); dict.Add("c", "c1"); string sKey = "a";
Judgment method 1:
if (dict.Keys.Any() = (e) => { 0 == string.Compare(e, sKey); }) { }
Judgment method 2:
string sValue = ""; if (dict.TryGetValue(sKey, out sValue)) { }
Method 2 is recommended.