Advanced Serialization

You’ve seen how basic serialization is performed and controlled using attributes. But at times you’ll need more control over how an object or a collection of objects is serialized and deserialized. We’ll look at this next.

Customizing Serialization

You can influence the format of the serialization stream used to serialize an object by implementing the System.Runtime.Serialization.ISerializable interface. This is useful if you need to perform some additional or nonstandard processing as part of the serialization process. A large number of classes in the .NET Framework Class Library implement the ISerializable interface.

For example, consider the FileStream member variable in the Widget class discussed in the previous section. ...

Get Microsoft® Visual J#™ .NET (Core Reference) now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.