static void Deserialize() { XmlSerializer xml = new XmlSerializer(typeof(CompNum)); using (FileStream fs = new FileStream("Baha.xml", FileMode.Open, FileAccess.Read)) { CompNum cn = xml.Deserialize(fs) as CompNum; cn.Show(); } }
static void Serialize() { CompNum cn = new CompNum() { a = 10, b = 7 }; XmlSerializer xml = new XmlSerializer(typeof(CompNum)); using (FileStream fs = new FileStream("Baha.xml", FileMode.Create, FileAccess.Write)) { xml.Serialize(fs, cn); } }