解决方法
您可以使用
ContainsKey和
string.Contains:
var key = "tester"; var val = "testing"; if(myDictionary.ContainsKey(key) && myDictionary[key].Contains(val)) { // "tester" key exists and contains "testing" value }
你也可以使用TryGetValue:
var key = "tester"; var val = "testing"; var dicVal = string.Empty; if(myDictionary.TryGetValue(key,out dicVal) && dicVal.contains(val)) { // "tester" key exists and contains "testing" value }