// 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.Xml.Serialization; class MainClass { public static void Main(string[] args) { Data tst = new Data(); tst.X = 123; Console.WriteLine(tst.X + " " + tst.X2); XmlSerializer ser = new XmlSerializer(typeof(Data)); ser.Serialize(Console.Out, tst); } } public class Data { private double x; [XmlElement(typeof(double))] public double X { get { return x; } set { x = value; } } [XmlElement(typeof(double))] public double X2 { get { return (x * 2); } } public Data() { x = 0; } }