NullProperty Sample

Back to summary

Source

using System.ComponentModel;

namespace XmlSerializersTest.Samples
{
    [Title("Null property")]
    public class NullProperty
    {
        public string NullString { get; set; }

        [DefaultValue(null)]
        public string NullStringWithDefault { get; set; }

        public MyClass CustomClassProperty { get; set; }
    }

    public class MyClass
    {
        public int SomeProperty { get; set; }
    }
}

WCF-ref Serializer

<NullProperty xmlns:i="http://www.w3.org/2001/XMLSchema-instance" z:Id="1" xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/" xmlns="http://schemas.datacontract.org/2004/07/XmlSerializersTest.Samples">
  <CustomClassProperty i:nil="true" />
  <NullString i:nil="true" />
  <NullStringWithDefault i:nil="true" />
</NullProperty>