Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            //Serilized Single Object
            SerializeSingleObject();

            //Serilized Multiple Object
            string xmlFilePath = SerializedMultipleObjects();

            Console.WriteLine("XML File Path:" + xmlFilePath);

            StudentClass students = XmlConvert.DeserializeObjects <StudentClass>(xmlFilePath);

            Console.ReadLine();
        }
Ejemplo n.º 2
0
        private static string SerializedMultipleObjects()
        {
            string       path     = Directory.GetCurrentDirectory() + "\\SerializedMultipleObjectsSerializedMultipleObjects.xml";
            Student      student  = new Student();
            var          students = student.GetStudents();
            StudentClass _class   = new StudentClass();

            _class.Students = students;
            string xmlString = XmlConvert.SerializeObject(_class);

            XmlConvert.SerializeObject(_class, path);
            Console.WriteLine(XDocument.Parse(xmlString).ToString());

            return(path);
        }