Blog de Francisco Velázquez

otro blog personal

Serialize/Deserialize

leave a comment »

using System.IO;
 using System.Xml;
 using System.Xml.Serialization;

private string serialize(System.Type type, Object data)
 {
 XmlSerializer xmlSerializer = new XmlSerializer(type);
 System.IO.TextWriter writer = new System.IO.StringWriter();
 xmlSerializer.Serialize(writer, data);
 writer.Close();
 return writer.ToString();
 }

private object deserialize(System.Type type, string data)
 {
 XmlSerializer xmlSerializer = new XmlSerializer(type);
 TextReader textReader = new StringReader(data);
 XmlReader xmlReader = new XmlTextReader(textReader);
 return xmlSerializer.Deserialize(xmlReader);
 }

Written by fravelgue

September 19, 2006 at 9:52 am

Posted in development

Tagged with , , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: