I have a class with numerous Nullable
Implement the IXmlSerializable
interface on your class. You can then handle special cases such as nullables in the ReadXML
and WriteXML
methods. There's a good example in the MSDN documentation page..
class YourClass : IXmlSerializable
{
public int? Age
{
get { return this.age; }
set { this.age = value; }
}
//OTHER CLASS STUFF//
#region IXmlSerializable members
public void WriteXml (XmlWriter writer)
{
if( Age != null )
{
writer.WriteValue( Age )
}
}
public void ReadXml (XmlReader reader)
{
Age = reader.ReadValue();
}
public XmlSchema GetSchema()
{
return(null);
}
#endregion
}