Serializing Objects
C# enables you to save an entire object, including all its data (called an object-graph) through a process called serialization. Serialization lets you write entire objects out to disk and read them back in later. Objects that pass between assembly boundaries (through a process called marshalling) are also serialized.
You use the BinaryFormatter class to serialize and deserialize objects; the significant public methods of this class appear in Table 5.19.
METHOD | DOES THIS |
---|---|
Deserialize | Deserializes a stream into an object-graph. |
Serialize | Serializes an object to the given stream. |
Here's an example, ch05_13.cs, which will serialize and deserialize an object. The ch05_13 class contains ...
Get Microsoft® Visual C#® .NET 2003 Kick Start 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.