I came across this question on transcender:
What should be applied to a field if its value is not required during deserialization?
Me = [NonSerialized], ANSWER = [OptionalField]
My gut reaction was NonSerialised, but Transcender says I'm wrong. I have a good idea of ββwhat to consider regarding the [Non-Specialized] attribute, but still I really would like this to be clarified.
As far as I can tell, the first one has relationships with version conflicts with older and older versions of the same assembly. The latter is more concerned with not serializing the FULLSTOP field. Is there anything else that could separate the two people? MSDN doesn't really talk about this, since they are both used in BinaryFormatters and SoapFormatter with XMLFormatter using XMLIgnoreAttribute.
My second question is: can you mix and match one of the two attributes? I have not used them yet.
Just tossing it, but my answer has to do with the [OnDeserialized] method and the IdeserilizationCallback interface is implemented?
UPDATE:
I know that the optional field attribute does not serialize the value held by the data member, but NonSerialized will not even serialize the data item or its value.
Ibrarmumtaz
source share