LINQ .ToDictionary for 2d字典

时间:2013-08-25 16:05:40

标签: c# linq dictionary todictionary

我在下面有3个词典:

Dictionary<string, int> A = new Dictionary<string, int>();
Dictionary<string, int> B = new Dictionary<string, int>();
Dictionary<int, Dictionary<int, int>> C = new Dictionary<int, Dictionary<int, int>>();

我想填写C Dictionary,默认值= 0,如下所示,我的代码不正确,请帮帮我

C = A.ToDictionary(x => x.Value, B.ToDictionary(y => y.Value, y => 0));

1 个答案:

答案 0 :(得分:3)

C = A.ToDictionary(x => x.Value, v=>B.ToDictionary(y => y.Value, y => 0));