1. Course
  2. Data serialization
  3. XmlSerialization: Serialize objects

XmlSerialization: Serialize objects


Last updated: 8/23/2020 Difficulty: Intermediate

Create a C# program to serialize and deserialize objects in XML format. To do this you can use the XmlSerialization class included in the System.Xml.Serialization namespace.

First implement a Person class with three properties (Name, Age and City). The City class will have two properties (Name and Population). Then create a person object and use the XmlSerialization object serializer to save the data in an xml file, later deserialize the file and print it on screen. Remember to prepare a ToString() method to print the Persona class.

Input


                    
                    

Output



                    

Solution

Data serialization

2 / 5

Android App


Practice C# anywhere with the free app for Android devices.

Android App

Exercises C# by difficulty


Learn C# at your own pace, the exercises are ordered by difficulty.

Advertising