I have an XSD.exe generated class. I am using a crude inversion of control. My test object worked until I added this fancy XML snippet:
<items>
<item>
<model>1000</model>
<description>Torque wrench</description>
<material>1545454</material>
<lot>3</lot>
<serial></serial>
<transferQty>1</transferQty>
<shipQty></shipQty>
</item>
<item>
//..item 2
</item>
<item>
//...item 3
</item>
</items>
</itemOrder>
Now, GeneratedByXsdClass object creation is busted.
GeneratedByXsdClass.items = new itemOrderItemsItem[][]{
new itemOrderItemsItem[1][]//this hardcoded 1 bothers me. better way?
{
new itemOrderItemsItem[]
{
new itemOrderItemsItem()
{
model = "1000",
description = "Torque Wrench",
material = "10002525",
lot = "3",
serial = "",
transferQty = "1",
shipQty = ""
}
}
}
};
Compiler Error:
Error 3 Cannot implicitly convert type 'itemOrderItemsItem[][]' to 'itemOrderItemsItem[]'
I’m open to modifying the xsd.exe generated class if that makes life easier. I really just want <item> to repeat N times.
Simplify your example down to this:
Now you should be able to see what the problem is; you’re trying to put an
int[][]inside anint[][], and the compiler is saying it expected aint[]. Remove the line with the comment:This is the equivalent in your code: