S
shrishjain
Hi,
Can someone tell me how can I seralize the following PurchaseOder class
to xml.
public class PurchaseOrder
{
[XmlElement(typeof(USAddress))]
public IUSAddress shipTo;
}
public class USAddress:IUSAddress
{
private string _city;
public string city
{
get {return _city;}
set{_city = value;}
}
}
public interface IUSAddress
{
string city{get; set;}
}
I use the following code to serialize, but it crash on first stament
itself:
XmlSerializer serializer = new XmlSerializer(typeof(PurchaseOrder));
PurchaseOrder po = new PurchaseOrder();
po.shipTo = new USAddress();
po.shipTo.city = "my city";
TextWriter writer = new StreamWriter("PurchaseOrder2.xml");
serializer.Serialize(writer, po);
writer.Close();
Any help will me greatly appreciated.
Thanks,
Shrish
Can someone tell me how can I seralize the following PurchaseOder class
to xml.
public class PurchaseOrder
{
[XmlElement(typeof(USAddress))]
public IUSAddress shipTo;
}
public class USAddress:IUSAddress
{
private string _city;
public string city
{
get {return _city;}
set{_city = value;}
}
}
public interface IUSAddress
{
string city{get; set;}
}
I use the following code to serialize, but it crash on first stament
itself:
XmlSerializer serializer = new XmlSerializer(typeof(PurchaseOrder));
PurchaseOrder po = new PurchaseOrder();
po.shipTo = new USAddress();
po.shipTo.city = "my city";
TextWriter writer = new StreamWriter("PurchaseOrder2.xml");
serializer.Serialize(writer, po);
writer.Close();
Any help will me greatly appreciated.
Thanks,
Shrish