LINQ .ToDictionary for 2d dictionary

本文关键字:dictionary 2d for ToDictionary LINQ | 更新日期: 2023-09-27 18:28:53

我下面有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>>();

我想用默认值=0填充C字典,如下所示,我的代码不正确,请帮助我

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

LINQ .ToDictionary for 2d dictionary

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