Serialising and Deserialising C# code to Xml
Hey there! I First of all, thank you for all the help on my "Classes" question. They helped a lot. Now i need to know how to serialize/deserialize a class from C# code, to Xml. Please note that i am working on a console app on .NetCore NOT in windows forms. I have already created a class with some properties, an empty constructor, and i called an instance of it in my main program. So how do i convert that to Xml, and where do i find the Xml file? I will include some code below. Thanks! //using Newtonsoft.Json; using System; using System.Collections.Generic; using System.ComponentModel; //using System.Data; //using System.DirectoryServices; //using System.DirectoryServices.AccountManagement; using System.IO; using System.IO.Compression; using System.Runtime.Serialization.Formatters.Binary; using System.Security; using System.Security.Cryptography; using System.Text; using System.Xml; using System.Xml.Linq; using System.Xml.Schema; using System.Xml.Serialization; namespace SerializeDesirialise { class Program { public class TestClass { public TestClass() { } public string name { get; set; } public int age { get; set; } public string gender { get; set; } } static void Main(string[] args) { TestClass Person = new TestClass(); Person.name = "Andrew"; Person.age = 5; Person.gender = "male"; } } }