Create a Serializable Object
Problem
You need to create an object that can be serialized (converted to a stream of bytes).
Solution
Add the Serializable attribute to your class.
Discussion
Serializable objects can be converted into a stream of bytes and recreated at a later point in time. You can use serialization to save an object to disk (as explained in recipe Serialize an Object to Disk) or to send an object between application domains with .NET Remoting (in which case, the .NET runtime manages the serialization and deserialization transparently).
In order for serialization to work, your object must meet all the following criteria:
The object must have a Serializable attribute preceding the class declaration.
All the public and private variables of ...
Get Microsoft® Visual Basic® .NET Programmer's Cookbook 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.