background preloader

XML Serialization

Facebook Twitter

C# Tutorial - XML Serialization. A long while ago we posted a tutorial on how to serialize objects to a binary file.

C# Tutorial - XML Serialization

While this is very useful, unfortunately the resulting file is not very human readable. In this tutorial, I'm going to demonstrate how to serialize your own objects to and from an XML file. Since .NET can use reflection to get property names, basic serialization is unbelievably simple. It only gets slightly difficult when you want to name your XML tags differently than your property names (but still not very hard). C# Tutorial - Serialize Objects to a File. While storing information in memory is great, there comes a time your users will have to shut your application down.

C# Tutorial - Serialize Objects to a File

This means (probably) that you will need to write information to a file at some point, because you will want to store whatever data was in memory. Today, we are going to take a look at a feature built into .NET called Serialization that makes writing and reading data structures to and from a file extremely easy. For this example, let's say I want to create a program that keeps track of all the cars my friends own. C# Tutorial - XML Serialization.