views:

414

answers:

2

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"

+2  A: 

This is how nulls are communicated in .NET XML serialization, the element doesn't exist.

+3  A: 

You must apply XmlElementAttribute:

[XmlElement(IsNullable = true)]
public string DummyField { get; set; }
arbiter