【发布时间】:2018-04-27 06:49:30
【问题描述】:
我有一个具有这种结构的 C# 字典:
Dictionary<int, Dictionary<string, double>> dictionary = new Dictionary<int, Dictionary<string, double>>
{
{
0, new Dictionary<string, double>
{
{ "eat",0.15 },
{ "food", 0.16 }
}
},
{
1, new Dictionary<string, double>
{
{ "eat",0.32 },
{ "food", 0.2 }
}
},
};
我想在其他字典中求和和相乘,
0.15 * 0.32 + 0.16 * 0.2
我应该怎么做才能用 foreach 在 c# 中编写代码?
谢谢
【问题讨论】:
标签: c# dictionary nested