O'Reilly logo

Visual Basic 2008 Recipes: A Problem-Solution Approach by Rakesh Rajan, Matthew MacDonald, Allen Jones, Todd Herman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

14.1. Implement a Serializable Type

Problem

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.

Solution

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required