// 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.Collections.Generic; using System.Xml.Serialization; namespace E { [Serializable] public class Data { public int V1 { get; set; } public string V2 { get; set; } public override string ToString() { return "(" + V1 + "," + V2 + ")"; } } [Serializable] public class DataList : List { public string S { get; set; } } public class Program { public static void Main(string[] args) { DataList lst = new DataList { S = "Overskrift" }; lst.Add(new Data { V1=123, V2="ABC" }); lst.Add(new Data { V1=456, V2="DEF" }); XmlSerializer ser = new XmlSerializer(typeof(DataList)); ser.Serialize(Console.Out, lst); } } }