Sample
code on XML and soap serialization
Serialization
is a process by which you can save an object in the form of a file or
in a database or in the memory to be used later. Serialization can be
done in different ways.
_______________________________________________
One
is Binary serialization, the other is XML serialization, and the final
one is the SOAP serialization. All these types of serialization are
supported in .Net.
With the
XML serialization you can serialize all the public properties and fields.
The private members cannot be serialized. Other types of serialization
should be used if you want to serialize the private members.
With this
type of serialization only the class that does not implement IDictionary
can be serialized. The IsNullable attribute is to be set to true if
you want to serialize the Null values. MemoryStream is used if you want
to store the object in the memory.
SOAP and
Binary serialization can be used to serialize the private fields. If
you do not want to serialize an object then you have to use the attribute
[NonSerialized]. You can mark the class as serializable with the [Serializable]
attribute.
Serializable
attribute cannot be inherited from the parent class. Make all the members
serialization to serialize a class. Classes that implement IDictionary
can be serialized with the SOAP and Binary serialization.
Lot of
code samples is available in the internet for serialization and deserialization.