Serializing with XML

Add a new console application project named WorkingWithSerialization.

To show a common example, we will define a custom class to store information about a person and then create an object graph using a list of Person instances with nesting.

Add a class named Person with the following definition. Notice that the Salary property is protected, meaning it is only accessible to itself and derived classes. To populate the salary, the class has a constructor with a single parameter to set the initial salary:

using System; using System.Collections.Generic; namespace Packt.CS7 { public class Person { public Person(decimal initialSalary) { Salary = initialSalary; } public string FirstName { get; set; } public string LastName { ...

Get C# 7 and .NET: Designing Modern Cross-platform Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.