OK The list of dictionaries is likely to complicate the issue too much. You get the same error only with this line:
var x = new Dictionary<string, string>() { "test", "" };
The problem is filling out the dictionary this way. If my example has been changed to:
var x = new Dictionary<string, string>(); x.Add("test", "");
and then back to the original example, this will work:
List<Dictionary<string, string>> data = new List<Dictionary<string, string>>(); var x = new Dictionary<string, string>(); x.Add("test", "" ); data.Add(x);
By the way, why do you need a list of dictionaries. Sounds like a pretty compiled design pattern to use - albeit technically sound.
source share