incrementing an array with in an array during xml serialization

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
 
M

[MSFT]

How about:

int rows = returnArray.GetLength(0); // Length of first dimension
int columns = returnArray.GetLength(1); // Length of second dimension

Make[] manufactor

manufactor= new Make[columns]

vehicle.Makes = manufactor;

for(int row = 0; row < rows; ++row)
{
vehicle.Makes[row]=returnArray[row,0];

...

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top