// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.IO; using System.Xml.Serialization; public struct Test { public int a; public double b; public string c; } class MainClass { public static void Main(string[] args) { Test tst; tst.a = 123; tst.b = 123.456; tst.c = "ABC"; XmlSerializer ser = new XmlSerializer(typeof(Test)); StreamWriter sw = new StreamWriter("C:\\test.xml"); ser.Serialize(sw, tst); sw.Close(); StreamReader sr = new StreamReader("C:\\test.xml"); Test tst2 = (Test)ser.Deserialize(sr); sr.Close(); Console.WriteLine(tst2.a + " " + tst2.b + " " + tst2.c); } }