- I am doing Binary Serilization of big nested data structure.
- Whenever [Serilizable] attribute is added to class, all the members are automatically serialized.
- I want to specifically select the fields that need to be serialized.
As of now i am using [NonSerialized] Attribute for fields to opt out from serilization.
Is there any way i can opt out all fields by default and then select only the fields i need, by usin开发者_JS百科g some attribute ?
You can control the serialization yourself by implementing ISerializable
and writing a serialization constructor. For more information, read this article.
If you use the DataContractSerializer, all the fields will be opted out by default. You will then be able to opt in your desired field using attributes.
精彩评论