Beispiel #1
0
        private void SerializeCollection(string filename)
        {
            /* Employees Emps = new Employees();
             * // Note that only the collection is serialized -- not the
             * // CollectionName or any other public property of the class.
             * Emps.CollectionName = "Employees";
             * Employee John100 = new Employee("John", "100xxxxxxxxxxxx");
             * Emps.Add(John100);
             * XmlSerializer x = new XmlSerializer(typeof(Employees));
             * TextWriter writer = new StreamWriter(filename);
             * x.Serialize(writer, Emps);*/

            ArrayList firstName = new ArrayList();

            firstName.Add("Nandy");
            firstName.Add("Karl");
            firstName.Add("Ferry");

            ArrayList lastName = new ArrayList();

            lastName.Add("Johnson");
            lastName.Add("Tomson");
            lastName.Add("Smithingson");
            lastName.Add("SJimmm");
            lastName.Add("Adventureman");

            Guild   Adventure = new Guild();
            Heroics newb      = new Heroics();

            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 5; j++)
                {
                    newb = new Heroics((string)firstName[i], (string)lastName[j], i + j);
                    Adventure.Add(newb);
                }
            }

            XmlSerializer xmlSerial = new XmlSerializer(typeof(Guild));
            TextWriter    writer    = new StreamWriter(filename);

            xmlSerial.Serialize(writer, Adventure);
        }
Beispiel #2
0
 public void Add(Heroics newHero)
 {
     heroArray.Add(newHero);
 }