I generated a new C# class from a XML file using xsd.exe:
test.xml
--------
<?xml version="1.0" encoding="UTF-8"?>
<Output>
<ReportType name="New Reports">
<Reports>
<Report name="report1">
<Items>
<Item name="item1">
<Value>1.00</Value>
</Item>
<Item name="item2">
<Value>2.00</Value>
</Item>
</Items>
</Report>
<Report name="report2">
<Items>
<Item name="item3">
<Value>3.00</Value>
</Item>
<Item name="item4">
<Value>4.00</Value>
</Item>
</Items>
</Report>
</Reports>
</ReportType>
</Output>
You can see the C# class it generates here.
Now I am trying to leverage the generated class to produce a new xml file and I need to set this variable:
private OutputReportTypeReportsReport[][] reportsField;
How do I initialize and add data to it?
You can do this:
OutputReportTypeReportsReport[][] reportsField = new OutputReportTypeReportsReport[100][];
reportsField [0] = new OutputReportTypeReportsReport[1] { object1 };
reportsField [1] = new OutputReportTypeReportsReport[2] { object2, object3 };
...
More info: http://msdn.microsoft.com/en-us/library/2s05feca.aspx
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.