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.
But I also do not want to change the value of the datamember, is there any other way of achieving this?
The serializer is DataContractSerializer. 🙂
Thanks.
You can change the value of the data member before the serialization (to the default value, so it doesn’t get serialized), but then after the serialization you’d change it back – using the
[OnSerializing]and[OnSerialized]callbacks (more information in this blog post). This works fine as long as you don’t have multiple threads serializing the object at the same time.