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


Top 5 Contributors of the Month
david stephan

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.



Description



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);
stream.Close();
obj = null;
//Deserialize the object
stream = File.Open("SampleData.xml", FileMode.Open);
formatter = new SoapFormatter();
obj = (TestSimpleObject)formatter.Deserialize(stream);
stream.Close();

     

Further Readings:

Responses

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