Reputation: 8349
I am trying to serialize an object that has nullable fields. If the field doesn't have any data in it the field is dropped from the serialized output. Any suggests on how to work around this? Is there a way to specify that nullable empty fields still get carried over?
This occurs when "propertyname_specified = false"
Upvotes: 0
Views: 1395
Reputation: 9605
You must apply XmlElementAttribute:
[XmlElement(IsNullable = true)]
public string DummyField { get; set; }
Upvotes: 3
Reputation: 1429
This is how nulls are communicated in .NET XML serialization, the element doesn't exist.
Upvotes: 2