M
Microsoft
I want to serialize a List<>. When I do I get an entry for each object in
the list but not the object's state.
My code:
//Person is a simple class that has fields for first and last name
List<Person> persons = new List<Person>();
XmlSerializer serializer = new XmlSerializer(typeof(List<Person>));
persons.Add(new Person("Joe", "Tester"));
persons.Add(new Person("Mary", "Tetser"));
serializer.Serialize(Console.Out, persons);
And I get...
<?xml version="1.0" encoding="IBM437"?>
<ArrayOfPerson xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="
http://www.w3.org/2001/XMLSchema">
<Person />
<Person />
</ArrayOfPerson>
Thank you for any help!
the list but not the object's state.
My code:
//Person is a simple class that has fields for first and last name
List<Person> persons = new List<Person>();
XmlSerializer serializer = new XmlSerializer(typeof(List<Person>));
persons.Add(new Person("Joe", "Tester"));
persons.Add(new Person("Mary", "Tetser"));
serializer.Serialize(Console.Out, persons);
And I get...
<?xml version="1.0" encoding="IBM437"?>
<ArrayOfPerson xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="
http://www.w3.org/2001/XMLSchema">
<Person />
<Person />
</ArrayOfPerson>
Thank you for any help!