Wednesday, July 20, 2011

Serialization in C#

Serialization is used to convert an object into a byte stream. This is usually done to store the object in the memory, database or a file and retrieve the state of the object later. This reverse process is called de-serialization.

To make a type serialize, you need to apply SerializeAttribute to it. If you haven't specify the attribute and when you try to serialize it, it'll through SerializationException. If you want to make some fields in your class not serialized, you can decorate it with NonSerializedAttribute. 

You cannot serialize iterator types such as IEnumerable etc. See SO

Binary Serialization 

Uses binary encoding to produce compact serialization. In Binary, all members are serialized. 

XML Serialization

Serializes public fields and properties of an object, or parameters and return values of a method. This serializes object into a XML stream. This provides more readable code.

SOAP Serialization

Serialize objects into XML streams which conforms to SOAP specification (which is a protocol based on XML).

Serialization in JavaScript
Convert form data to JSON using JQuery

Sources
Powered by Blogger.


Software Architect at Surge Global/ Certified Scrum Master

Experienced in Product Design, Software Engineering, Team management and Practicing Agile methodologies.

Search This Blog

Facebook