public static void Serialize(TestSerializeableClass tsc) { XmlSerializer serializer = new XmlSerializer(typeof(TestSerializeableClass)); using (TextWriter writer = new StreamWriter(@"C:\Xml.xml")) { serializer.Serialize(writer, tsc); } }
static void Main(string[] args) { TestSerializeableClass tsc = new TestSerializeableClass(); TestNestedClass tnc = new TestNestedClass(); tnc.AttributeInt = 2; tnc.AttributeString = "Nested Att"; tsc.TestNestedClass = tnc; tsc.AttributeInt = 1; tsc.AttributeString = "Serialize"; Serialize(tsc); }