Serialization

Serialization is the capability to save the state of an object to a stream for later recovery. This is common for distributed network communications technologies such as remoting and Web services. Serialization may be performed automatically with attributes or with a customized solution.

Automatic Serialization

Automatic serialization occurs by adding C# elements, known as attributes, to a class and, optionally, its members. These are the Serializable and NonSerialized attributes as demonstrated in Listing 17.6. Attributes are discussed in detail in a later chapter.

Listing 17.6. Automatic Serialization: Serialized.cs
 using System; using System.IO; using System.Text; using System.Runtime.Serialization; using System.Runtime.Serialization.Formatters.Binary; ...

Get C# Unleashed 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.