I only want only to de-serializing a certain data member, without serializing it.
I understand I can set EmitDefaultValue =false, and set the value to null.
<
Which serializer?If this is XmlSerializer
then either:
public int Foo {get;set;}
[XmlIgnore]
public bool FooSpecified {
get { return false; } // never serialize
set { }
}
or
public int Foo {get;set;}
public bool ShouldSerializeFoo() { return false; }
will do this. A quick test shows that this doesn't work for DataContractSerializer
, though. protobuf-net also supports both of these, for info.