namespace XML_Test { class Program { static void Main(string[] args) { Test t = new Test(); t.Foo = "TEST"; t.Privstring = "Another String"; XmlSerializer ser = new XmlSerializer(typeof(Test)); FileStream fs = new FileStream("C:\\Pat\\test.xml", FileMode.OpenOrCreate); ser.Serialize(fs,t); fs.Close(); XmlSerializer ser2 = new XmlSerializer(typeof(Test2)); FileStream instream = new FileStream("C:\\Pat\\test.xml", FileMode.Open); //if (ser.Deserialize(instream)) Test2 deserialize = (Test2)ser2.Deserialize(instream); //Console.Read(); } } [Serializable] public class Test { public string Foo; public string Privstring; } [Serializable] public class Test2 { public string Foo; public string Privstring; } }
Test1 deserialize = (Test1)ser.Deserialize(instream);
Test2 deserialize = (Test2)ser2.Deserialize(instream);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)