我有一段代码代表字典和搜索键数组。
Dictionary<string, string> items = new Dictionary<string, string>()
{
{"1","Blue"},
{"2","Green"},
{"3","White"}
};
string[] keys = new[] { "1", "2", "3", "4" };
当我传递字典中不存在的键时,如何安全地避免运行时错误?