Assuming I have the following:
[Serializable]
public class Foo
{
public Bar bar
{
get;
set;
}
public Ram ram
{
get;
set;
}
}
[Serializable]
public class Bar
{
[XmlElement("barId")]
public int Id
{
get;
set;
}
}
[Serializable]
public class Ram
{
[XmlElement("ramId")]
public int RamId
{
get;
set;
}
}
I would like to serialize to XML as:
<Foo>
<barId>123</barId>
<ramId>234</ramId>
</Foo>
What is the best way to do this?
I think I will have to create an intermediary class to serialize. Alternatives?