我想在另一个Dictionary
中使用Dictionary
作为TKey
。类似于Python的东西。我试过这个,但它给我错误。使用字典作为其他字典中的关键字
Dictionary<Dictionary<string, string>, int> dict = new Dictionary<Dictionary<string, string>, int>();
Dictionary<string, string> dict2 = new Dictionary<string, string>();
dict2["abc"] = "def";
dict[dict["abc"] = 20;
您的最后一行有多个错误。如果其中一个引用应该是dict2,则可以参考字典两次。 (重要的一课:清楚地说明你的变量!)你有一个无与伦比的开放大括号。 – abelenky 2009-01-11 19:06:44