0

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
  • I would like to suggest that you accept the answer that you like by clicking on the green check mark. It will give positive feedback to the people that answered your question, and a way of saying "thank you for answering my question" Commented Jul 17, 2009 at 18:57
  • If the field is null, what did you expect to see in the XML? Commented Jul 25, 2009 at 19:17

2 Answers 2

3

You must apply XmlElementAttribute:

[XmlElement(IsNullable = true)]
public string DummyField { get; set; }
Sign up to request clarification or add additional context in comments.

Comments

2

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.