我有這樣一個字典結構:獲取值的總和嵌套字典
Dictionary<string, Dictionary<int, double>> temp =
new Dictionary<string, Dictionary<int, double>>();
我想使用LINQ來計算temp
所有雙值的總和。我試圖獲得字典清單List<Dictionary<int, double>> res = temp.Values.Select(s => s).ToList();
,但不知道如何前進與此。
這個怎麼樣:var results = temp.Select(x => new {key = x.Key,sum = x.Value.Select y => y.Value).Sum()})。ToList(); – jdweng