What is the use of serializable keyword in C#?

When you create an object in a .Net framework application, you don't need to think about how the data is stored in memory. Because .Net framework takes care of that for you. However, if you want to store the contents of an object to a file, send an object to another process or transmit it across the network, you do have to think about how the object is represented because you will need to convert it to a different format. This conversion is called SERIALIZATION.
 
Serialization allows the developer to save the state of an object and recreate it as needed, providing storage of objects as well as data exchange. Through serialization, a developer can perform actions like sending the object to a remote application by means of a Web Service, passing an object from one domain to another, passing an object through a firewall as an XML string, or maintaining security or user-specific information across applications.

Bulkmailstack
 
The simplest way to make your classes eligible for serialization is to use the Serializable attribute. By decorating your class with this attribute as shown below, your classes are immediately made serializable:

[Serializable]
public class Player
{
[...]
}


Serialization is the process of taking an object and convert it to a format that can be transmitted over the network or save in database or store in the file.

Objects may be serialized in three formats: Binary Soap and XML.

Remoting and Web Services depend heavily on Serialization and De-serialization.


Deliver2inbox
 
Back
Top