我有一个字典对象:asp.net字典<字符串,字符串>更新项基于键值
protected Dictionary<string,string> myDict;
我想能够搜索字典经由键和更新的该值键/值对。
if (!myDict.ContainsKey(key))
{
myDict.Add(key, value); //if key is not found in the collection add it.
}
else //if it is found then update it.
{
Update[Key].Value with myValue
}
有没有办法做到以上几点?如何通过检查密钥来更新密钥的值? 在else语句中匹配伪代码的实际代码是什么?
啊是的。我正在尝试myDict.Keys [键],这就是为什么它不起作用。语法错了。谢谢。 – 2013-03-24 14:47:14