定义Dictionary对象并添加内容
Dictionary<string, string> dict = new Dictionary<string, string>() { };
dict.Add("a", "a1");
dict.Add("b", "b1");
dict.Add("c", "c1");
string sKey = "a";
判断方法1:
if (dict.Keys.Any() = (e) => { 0 == string.Compare(e, sKey); })
{
}
判断方法2:
string sValue = "";
if (dict.TryGetValue(sKey, out sValue))
{
}
推荐使用方法2。