我有一份清单:
List<Dictionary<string, string>> testList= new List<Dictionary<string, string>>();
那么如何从每个字典中获取值呢?
我知道我可以通过索引获得字典,如下所示:
testList[index]
但是我不知道如何从Dictionary
获取一个键的值。
发布于 2016-07-29 07:33:05
使用
var value = testList[index][key]
您将从列表中的字典中获取值。
发布于 2016-07-29 07:33:22
使用:
testList[int][TKey]
Dictionary<object, object>
有一个项目属性Item[TKey]
testList[int].Add("apple", 1);
if (testList[int].ContainsKey("apple"))
{
int value = testList[int]["apple"];
Console.WriteLine(value);
}
https://stackoverflow.com/questions/38652982
复制相似问题