Exemplo n.º 1
0
        public void Serialize(MarkList MRK)
        {
            FileStream    fs = new FileStream("marks.xml", FileMode.OpenOrCreate, FileAccess.ReadWrite);
            XmlSerializer xs = new XmlSerializer(typeof(MarkList));

            xs.Serialize(fs, MRK);
            fs.Close();
        }
Exemplo n.º 2
0
        public void DeSerialize()
        {
            FileStream    fs  = new FileStream("marks.xml", FileMode.OpenOrCreate, FileAccess.ReadWrite);
            XmlSerializer xs  = new XmlSerializer(typeof(MarkList));
            MarkList      MRK = xs.Deserialize(fs) as MarkList;

            for (int i = 0; i < MRK.Marks.Count; i++)
            {
                Console.WriteLine(MRK.Marks[i]);
            }
            fs.Close();
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            Mark     m1  = new Mark(95);
            Mark     m2  = new Mark(85);
            Mark     m3  = new Mark(57);
            MarkList MRK = new MarkList();

            MRK.Marks.Add(m1);
            MRK.Marks.Add(m2);
            MRK.Marks.Add(m3);
            MRK.Serialize(MRK);
            MRK.DeSerialize();
            Console.ReadKey();
        }