Prevent <xsi:nil="true"> on Nullable Value Types when Serializing to XML.

Posted by Nat Ryall on Stack Overflow See other posts from Stack Overflow or by Nat Ryall
Published on 2010-02-12T14:54:53Z Indexed on 2010/06/06 12:32 UTC
Read the original article Hit count: 276

I have added some nullable value types to my serializable class. I perform a serialization using XmlSerializer but when the value is set to null, I get an empty node with xsi:nil="true". This is the correct behaviour as I have found here: http://msdn.microsoft.com/en-us/library/ybce7f69%28VS.80%29.aspx

Is there a way to switch off this option so that nothing is output when the value type is null?

© Stack Overflow or respective owner

Related posts about .NET

Related posts about serialization