C# - XML Serialization

C# XML Serialization can be done by

1. Create a serializable class
2. Use a XmlSerializer to serialize and deserialize
3. Use TextWriter and FileStream to write and read from file respectively.

Below are very sample code

A Serializable class - It is a C# class with [Serializable] tag



Write serializable object to xml file




Read xml file and deserialize into object



The resulting xml is



Comments

Popular Posts