Serialization is the process of converting an object into a
stream of bytes which is easily transferable over the network and storing its
current state on any permanent storage media like file or database for later use.
De-serialization is the reverse process of Serialization, where the stored
object is taken and the original object is recreated.
.NET provides classes through its
System.Runtime.Serialization namespaces that can be used for serializing and de-serializing
objects.
Figure 1: Serialization and De-serialization
Serialization can be divided into following types:
·
Binary Serialization: Binary
serialization allows the serialization of an object into a binary stream and
restoration from a binary stream into an object.
·
XML Serialization: XML serialization
allows the public properties and fields of an object to be reduced to an XML
document that describes the publicly visible state of the object.
·
SOAP Serialization: SOAP serialization
is similar to XML serialization in that the objects being serialized are
persisted as XML.
·
Custom Serialization: If the default
serialization classes are insufficient due to the requirements, then this can
be customized by implementing the ISerializable interface.
We will be dealing only with Binary Serialization as it is
used for serialization in databases. In .NET, this facility is provided by the
BinaryFormatter class present in System.Runtime.Serialization.Formatters.Binary
namespace.