XmlSerialize and nullable types
-
Hello I am new to XmlSerializing and I got a problem when trying to serialize a nullable int. The thing I serialize look like this
private int? length; public int? Length { get { return this.length; } set { this.length = value; } }
But when I serialize this, and it is null, the output looks like this:<Length d3p1:nil="true" xmlns:d3p1="http://www.w3.org/2001/XMLSchema-instance" />
What I want it to do is, when the int is null, I want it to be ignored and thereby not having any output to my xml-file. I could make my int to a string and then convert the string to an int whenever I need, but that doesnt seem to be a good solution to me. So, does any of you know a way to XmlSerialize an int and then if it is null, it shouldt be showed in the xml-file, or a good article/something? //QzRz