This is duplicate of http://stackoverflow.com/questions/306877/can-xmlserializer-deserialize-into-a-nullableint but I need a solution that neither change xml document nor forces me to implement IXmlSerializable interface. I dont want to implement IXmlSerializable because I have many additional elements beside <number
> that get deserialized correctly.
My xml can contain either element <number>4</number>
or <number/>
<root>
...
either <number>4</number> or <number/>
... [other elements]
</root>
Class
public class root
{
public int? number {get; set;}
...
}
does not work.