我似乎无法正确使用此语法或任何具有此示例的资源。
尝试类似的事情:
Row = new Dictionary<string, string> [] [{"A":"A"}, {"B":"B"}]
有关此语法的想法吗?
答案 0 :(得分:4)
您可以尝试这种方式:
Row = new Dictionary<string, string>[]
{
new Dictionary<string, string> { {"A", "A"} },
new Dictionary<string, string> { {"B", "B"} }
};
答案 1 :(得分:3)
对数组和内部collection initializers使用dictionaries:
var arrayOfDictionaries = new Dictionary<string, string>[]
{
new Dictionary<string, string>() { {"A", "A"} },
new Dictionary<string, string>() { {"B", "B"} }
};