G
Guest
I'm unable to increment the index in an array in which I'm stuffing another array. Would someone help me with this
I'm inserting the namespace in this mail so you can see my code. thanks ahead of tim
using System
using System.IO
using System.Xml
using System.Xml.Schema
using System.Xml.Serialization
using EXstub
namespace xmltex
/// <summary
/// Summary description for xmlTest
/// </summary
[Serializable
public class xmlTes
public xmlTest(
/
// TODO: Add constructor logic her
/
[Serializable
public class Mak
[XmlAttribute(AttributeName="makeame")
public string MakeName
[Serializable
public class Mode
[XmlAttribute(AttributeName="modelname")
public string ModelName
[Serializable
public class Yea
[XmlAttribute(AttributeName="year")
public string YearMade
[Serializable
[XmlRoot(ElementName="vehicles")
public class Vehicl
[XmlArrayAttribute("makes")
[XmlArrayItemAttribute("make")
public Make[] Makes
[XmlArrayAttribute("models")
[XmlArrayItemAttribute("model")
public Model[] Models
[XmlArrayAttribute("years")
[XmlArrayItemAttribute("year")
public Year[] Years
public class Serializer
public Serializer(
/
// TODO: Add constructor logic her
/
public Vehicle serializer(
Vehicle vehicle = CreateVehicle()
XmlSerializer serializer = new XmlSerializer(typeof(Vehicle))
using (FileStream stream = File.OpenWrite("Vehicle.xml"))
serializer.Serialize(stream,vehicle)
return vehicle
private static Vehicle CreateVehicle()
EXstub.dummy exStub = new EXstub.dummy()
string[,] returnArray = exStub.buildArray();
Vehicle vehicle = new Vehicle()
Make make = new Make()
Model model = new Model()
Year year = new Year()
int rows = returnArray.GetLength(0); // Length of first dimensio
int columns = returnArray.GetLength(1); // Length of second dimensio
for(int row = 0; row < rows; ++row)
make.MakeName = returnArray[row,0];
Make[] manufactor = {make}
These are the vehicle.Makes = manufactor
line, same for each
model.ModelName=returnArray[row,1]
Model[] style = {model}
vehicle.Models = style
year.YearMade=returnArray[row,2]
Year[] yr = {year}
vehicle.Years = yr
return vehicle
I'm inserting the namespace in this mail so you can see my code. thanks ahead of tim
using System
using System.IO
using System.Xml
using System.Xml.Schema
using System.Xml.Serialization
using EXstub
namespace xmltex
/// <summary
/// Summary description for xmlTest
/// </summary
[Serializable
public class xmlTes
public xmlTest(
/
// TODO: Add constructor logic her
/
[Serializable
public class Mak
[XmlAttribute(AttributeName="makeame")
public string MakeName
[Serializable
public class Mode
[XmlAttribute(AttributeName="modelname")
public string ModelName
[Serializable
public class Yea
[XmlAttribute(AttributeName="year")
public string YearMade
[Serializable
[XmlRoot(ElementName="vehicles")
public class Vehicl
[XmlArrayAttribute("makes")
[XmlArrayItemAttribute("make")
public Make[] Makes
[XmlArrayAttribute("models")
[XmlArrayItemAttribute("model")
public Model[] Models
[XmlArrayAttribute("years")
[XmlArrayItemAttribute("year")
public Year[] Years
public class Serializer
public Serializer(
/
// TODO: Add constructor logic her
/
public Vehicle serializer(
Vehicle vehicle = CreateVehicle()
XmlSerializer serializer = new XmlSerializer(typeof(Vehicle))
using (FileStream stream = File.OpenWrite("Vehicle.xml"))
serializer.Serialize(stream,vehicle)
return vehicle
private static Vehicle CreateVehicle()
EXstub.dummy exStub = new EXstub.dummy()
string[,] returnArray = exStub.buildArray();
Vehicle vehicle = new Vehicle()
Make make = new Make()
Model model = new Model()
Year year = new Year()
int rows = returnArray.GetLength(0); // Length of first dimensio
int columns = returnArray.GetLength(1); // Length of second dimensio
for(int row = 0; row < rows; ++row)
make.MakeName = returnArray[row,0];
Make[] manufactor = {make}
These are the vehicle.Makes = manufactor
line, same for each
model.ModelName=returnArray[row,1]
Model[] style = {model}
vehicle.Models = style
year.YearMade=returnArray[row,2]
Year[] yr = {year}
vehicle.Years = yr
return vehicle