class Arwen { private Hashtable table = new Hashtable(); private TimeSpan time = new TimeSpan(0, 0, 1); public Hashtable Table { get { return table; } set { table = value; } } public TimeSpan Time { get { return time; } set { time = value; } } public string Name { get; set;} }
using System.Xml.Serialization; using System.IO; class Arwen { private Hashtable table = new Hashtable(); private TimeSpan time = new TimeSpan(0, 0, 1); public Arwen() { } [XmlIgnoreAttribute] public Hashtable Table { get { return table; } set { table = value; } } [XmlIgnoreAttribute] public TimeSpan Time { get { return time; } set { time = value; } } } Arwen weiwen = new Arwen(); weiwen.Time = new TimeSpan(1,2,3); // 1 hours , 2 minutes, 3 seconds weiwen.Table.Add("arwen", 250); string filename = @"c:/temp/arwen.xml"; XmlSerializer xs = new XmlSerializer(typeof(Arwen)); using (FileStream file = new FileStream(filename, FileMode.Create)) xs.Serialize(file, sa);