14.1. Implement a Serializable Type


You need to implement a custom type that is serializable, allowing you to do the following:

  • Store instances of the type to persistent storage (for example, a file or a database).

  • Transmit instances of the type across a network.

  • Pass instances of the type "by value" across application domain boundaries.


For serialization of simple types, apply the attribute System.SerializableAttribute to the type declaration. For types that are more complex, or to control the content and structure of the serialized data, implement the interface System.Runtime.Serialization.ISerializable.

How It Works

Recipe 2-13 showed how to serialize and deserialize an object using the formatter classes provided with the .NET ...

Get Visual Basic 2008 Recipes: A Problem-Solution Approach now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.