第一Dictionary
就像C#:字典的转换<字符串,字符串>到词典<字符串,字典<字符串,字符串>>
Dictionary<String, String> ParentDict = new Dictionary<String, String>();
ParentDict.Add("A_1", "1");
ParentDict.Add("A_2", "2");
ParentDict.Add("B_1", "3");
ParentDict.Add("B_2", "4");
ParentDict.Add("C_1", "5");
我需要此转换为一个新的Dictionary<String, Dictionary<String,String>>
结果将包含
Key Value
Key Value
_________________________________________________
"A" "A_1" "1"
"A_2" "2"
"B" "B_1" "1"
"B_2" "2"
"C" "C_1" "1"
现在我使用nested for loop
来做到这一点。
我如何使用LNQ
或LAMBDA Expression
来做到这一点?
为什么你需要这个数据结构? – 2010-10-23 14:26:31
我问的原因是嵌套字典通常比带有复合键或查找的单深度字典慢和不太合适。 – 2010-10-23 14:29:31