Book contents
- Frontmatter
- Contents
- Preface
- Chapter 1 An Overview of the Visual Basic.NET Language
- Chapter 2 An Overview of Object-Oriented Programming
- Chapter 3 Structures
- Chapter 4 Classes
- Chapter 5 Access Modifiers
- Chapter 6 Abstract Classes and Interfaces
- Chapter 7 Implementing the IEnumerable and IComparable Interfaces
- Chapter 8 Designing and Implementing Exception Classes
- Chapter 9 Design Patterns and Refactoring
- Chapter 10 Object Internals: Reflection and Attributes
- Chapter 11 Object Persistence: Serialization
- Chapter 12 Building a Windows Application
- Chapter 13 Database Programming Using ADO.NET
- References
- Index
Chapter 11 - Object Persistence: Serialization
Published online by Cambridge University Press: 06 July 2010
- Frontmatter
- Contents
- Preface
- Chapter 1 An Overview of the Visual Basic.NET Language
- Chapter 2 An Overview of Object-Oriented Programming
- Chapter 3 Structures
- Chapter 4 Classes
- Chapter 5 Access Modifiers
- Chapter 6 Abstract Classes and Interfaces
- Chapter 7 Implementing the IEnumerable and IComparable Interfaces
- Chapter 8 Designing and Implementing Exception Classes
- Chapter 9 Design Patterns and Refactoring
- Chapter 10 Object Internals: Reflection and Attributes
- Chapter 11 Object Persistence: Serialization
- Chapter 12 Building a Windows Application
- Chapter 13 Database Programming Using ADO.NET
- References
- Index
Summary
Serialization is the process of capturing the current state of a class object and writing the state to disk. Serialization allows you to make a class object persistent, which means that you can save the current state of an object while a program is running and at a later time retrieve that state and continue using the object. In this chapter, we'll show you how to perform both serialization and deserialization, which is retrieving an object's state from disk.
SERIALIZATION DEFINED
Serialization in VB.NET involves writing out the state of a class object as a series of bytes to a byte stream. The CLR writes out a class object as an object-graph, which consists of the class object and all the member data associated with the object. To let the CLR know that a class can be serialized, it must be marked with the Serializable attribute.
Although classes must be marked to be serialized, primitive types do not have to be marked as such. Therefore, all the primitive types within your class definition will be serialized automatically when the class is marked Serializable. Other objects (such as nested classes) within a class definition must be tagged with the Serializable attribute if they are to be serialized with the rest of the class types.
A class is physically serialized using a formatter. A formatter, as its name suggests, defines the format of the data stream that is written to disk.
- Type
- Chapter
- Information
- Object-Oriented Programming with Visual Basic.NET , pp. 252 - 259Publisher: Cambridge University PressPrint publication year: 2004