I am using XmlConvert
. For the one instance of Class
, only one property will have a value, another will be empty.
public class Class
{
[XmlAttribute("ValueA")]
public decimal? ValueA { get; set; }
[XmlAttribute("ValueB")]
public decimal? ValueB { get; set; }
}
The problem here is that the serializer can't serialize null property. How can I show only one property with value? Example:
var item = new Class { ValueA = 1, ValueB = null}
<?xml version="1.0" encoding="utf-8"?>
<model>
<ValueA>1</ValueA>
</model>