I have a DateTime and a subclass that I want formatted specifically on XML serialization. Normally, without specifying anything, serialization of a DateTime would just follow the current culture, but I want DateTime formatted in a certain way (even if not deserializable), ditto the subclass.
So, given these classes:
public class MyClass
{
public DateTime MyDateTime { get; set; }
public MySubClass TheSubClass { get; set; }
}
public class MySubClass
{
public int ID { get; set; }
public string Name { get; set; }
}
How do I specify serialization methods that would output:
<MyClass>
<MyDateTime>2011-9-13T10:30:00Z</MyDateTime>
<MySubClass>ID-Name</MySubClass>
</MyClass>