No best type found for implicitly-typed array
It's because you have two different anonymous types in the first example, the definition of the last item is different than the other ones.
In the first example , one containing an A
property and one containing a B
property, and the compiler can't figure out the type of array. In the second example there is one anonymous type, containing only A
.
I think it's a typo, so you can change B
to A
in last entry in first example
From MSDN:
You can create an implicitly-typed array in which the type of the array instance is inferred from the elements specified in the array initializer.
You can use:
var marketValueData = new object[] {
new { A = "" },
new { A = "" },
new { B = "" },
...,
};