.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal

Home >> Code Snippets >> Network >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Serialization - by SoapFormatter

Posted By:nishithraj       Posted Date: November 27, 2009    Points: 10    Category: Network    URL: http://www.dotnetspark.com  

Serialization - by SoapFormatter.


Serialization is the process of converting an object in to a stream of portable bytes. We can convert an object in to xml format by using XmlSerializer or SOAP Formatter. In the formatters itself we have two types.

They are
1) SoapFormatter(Earlier mentioned)
2) Binary Formatter

Deserialization is the reversal process of serialization.
Here is a sample code for serialization(SOAP Formatter)

TestSeriablize obj = new TestSeriablize();
Stream stream = File.Open("SampleData.xml", FileMode.Create);
SoapFormatter formatter = new SoapFormatter();
//Serialize the object using SOAP
formatter.Serialize(stream, obj);
obj = null;
//Deserialize the object
stream = File.Open("SampleData.xml", FileMode.Open);
formatter = new SoapFormatter();
obj = (TestSimpleObject)formatter.Deserialize(stream);


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend