查询词典的词典? [英] Query a Dictionary of Dictionaries?
本文介绍了查询词典的词典?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请你能告诉我如何查询词典的词典,和/或清单字典?
Please can you advise me on how to query a Dictionary of Dictionaries, and/or a Dictionary of List?
private Dictionary<string, Dictionary<DateTime, double>> masterDict= new Dictionary<string, Dictionary<DateTime, double>>();
Private Dictionary<string, List<DateTime>> masterList= new Dictionary<string, List<DateTime>>();
我知道,如果我这样做,我得到包含在masterDict的词典列表,但我不知道如何让那些字典的值。
I know if I do the following, I get a list of the dictionaries contained in masterDict, but I'm not sure how to get at the values of those dictionaries.
foreach (var kvp in masterDictMethod())
{
Console.WriteLine("Key = {0}, Value = {1}",
kvp.Key, kvp.Value);
}
感谢您寻找;)
Thanks for looking ;)
推荐答案
在你的foreach kvp.Value
是每个masterDict入口即词典&LT;日期时间,双&GT;
In you foreach kvp.Value
is the inner dictionary of every masterDict entry i.e. Dictionary<DateTime, double>
所以,也只是foreach的, kvp.Value
,你会得到的内在价值。
So, just foreach also over kvp.Value
and you will get the inner values.
例如。
foreach (var kvp1 in masterDictMethod())
{
Console.WriteLine("Key = {0}, Inner Dict:", kvp1.Key);
foreach (var kvp2 in kvp1.Value)
{
Console.WriteLine("Date = {0}, Double = {1}", kvp2.Key, kvp2.Value);
}
}
这篇关于查询词典的词典?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文