Assembly (reference)
System.Xml
Using directive
using System.Xml.Serialization;
Code: Creation of the serializer
The following code generates a serialization assembly on the fly (on first execution). This assembly is then used to read and write objects of the specified type.
XmlSerializer s = new XmlSerializer( typeof( MyType ) );
Code: Serialization
using (TextWriter writer = new StreamWriter( "data.xml" ))
{
s.Serialize( writer, myObject );
}
Code: Deserialization
using (TextReader reader = new StreamReader( "data.xml" ))
{
myObject = (MyType)s.Deserialize( reader );
}







