What is Serialization in C#? Example.

Answer :
When we want to transport an object through network then we need to convert the object into a stream of bytes. Serialization is a process to convert a complex objects into stream of bytes for storage (database, file, cache, etc) or transfer. Its main purpose is to save the state of an object.
De-serialization is the reverse process of creating an object from a stream of bytes to their original form.
Question 2. What Are The Types Of Serialization?
Answer :
The types of Serializations are given bellow:
1  Binary Serialization
            In this process all the public, private, read only members are serialized and convert into stream of bytes. This is used when we want a complete conversion of our objects.
2  SOAP Serialization
           In this process only public members are converted into SOAP format. This is used in web services.
3  XML Serialization
            In this process only public members are converted into XML. This is a custom serialization. Required namespaces: System.Xml, System.Xml.Serialization.
Question 3. Why Serialization And Deserialization?
Answer :
For example consider, we have a very complex object and we need XML format to show it on HTML page. Then we can create a XML file in the disk, writes all the necessary data on the XML file, and use it for the HTML page. But this is not good approach for large number of users. Extra space is required; anyone can see the XML file which creates security issue. We can overcome it by using XML serialization.
Question 4. When To Use Serialization?
Answer :
Serialization is used in the following purposes:
To pass an object from on application to another
In SOAP based web services
To transfer data through cross platforms, cross devices
Share:

No comments:

Post a Comment

Tuesday, 2 July 2019

What is Serialization in C#? Example.

Answer :
When we want to transport an object through network then we need to convert the object into a stream of bytes. Serialization is a process to convert a complex objects into stream of bytes for storage (database, file, cache, etc) or transfer. Its main purpose is to save the state of an object.
De-serialization is the reverse process of creating an object from a stream of bytes to their original form.
Question 2. What Are The Types Of Serialization?
Answer :
The types of Serializations are given bellow:
1  Binary Serialization
            In this process all the public, private, read only members are serialized and convert into stream of bytes. This is used when we want a complete conversion of our objects.
2  SOAP Serialization
           In this process only public members are converted into SOAP format. This is used in web services.
3  XML Serialization
            In this process only public members are converted into XML. This is a custom serialization. Required namespaces: System.Xml, System.Xml.Serialization.
Question 3. Why Serialization And Deserialization?
Answer :
For example consider, we have a very complex object and we need XML format to show it on HTML page. Then we can create a XML file in the disk, writes all the necessary data on the XML file, and use it for the HTML page. But this is not good approach for large number of users. Extra space is required; anyone can see the XML file which creates security issue. We can overcome it by using XML serialization.
Question 4. When To Use Serialization?
Answer :
Serialization is used in the following purposes:
To pass an object from on application to another
In SOAP based web services
To transfer data through cross platforms, cross devices

No comments:

Post a Comment

Popular

Total Pageviews

Archive