Esempio n. 1
0
        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();
            }
        }
Esempio n. 2
0
        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);
            }
        }