I have thw following XML Code that I want to deserialize:
<a>
<b> n/a </b>
</a>
Now b is normally an integer, but sometimes “n/a” for not available. Whenever I deserialize the above XML, I get an Exception that I use a wrong format… what is correct.
But I need the int simply to be a null value
public class a
{
Nullable<int> b;
}
The only way you could do that would be to use something like:
Here:
Bis theint?we’ll use to store the dataBSerializedis a shim property that handles the parsing etcShouldSerializeBSerializedensures we only serialize valid data