Monday, March 14, 2011

Xml Serialization and Deserialization of Complex Objects/Lists

what isn't really made clear here is that you have to pass into the XMLSerializer constructor all the types that will come in the nested types of the objects. you can do this e.g.

public class Class1
public static Type[] extraTypes = new Type[] { typeof(Class2), typeof(Class3) }

private list1 List = new List();
public List
get ..
set ..
... same for Class3 ..

Then you need to create the xml serializer as XmlSerializer(typeof(Class1), Class1.extraTypes)

No comments:

Post a Comment