Customizing the Serialization Process
At this point, every data member contained within the StateInfo class will be serialized and written to disk. However, there may be times when a certain variable does not need to be serialized. To prevent a variable from being serialized, apply the NonSerialized attribute to each data member that doesn't need to be serialized. As you may have guessed, the private member variable m_pstrNonSerialized will be marked as nonserialized, so apply the NonSerialized attribute to that variable, as shown on line 51 of Listing 24.2. The process of marking individual members as nonserialized is known as selective serialization.
You can further customize the serialization process by implementing the ISerializable interface ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access