1 public class XMLTest 2 { 3 [Test] 4 public static void Test() 5 { 6 Name1 name = new Name1(); 7 name.Id = "1"; 8 9 List<Name1> names = new List<Name1>(); 10 names.Add(name); 11 names.Add(name); 12 13 Person person = new Person(); 14 person.Obj = names; 15 16 // Serialize 17 string xml = XmlUtil.Serializer(typeof(Person), person); 18 MessageBox.Show(xml); 19 20 Person p = (Person)XmlUtil.Deserialize(typeof(Person), xml); 21 MessageBox.Show(((p.Obj) as List<Name1>)[0].Id); 22 } 23 } 24 25 [XmlInclude(typeof(List<Name1>))] 26 public class Person 27 { 28 [XmlElement(Namespace = "")] 29 public Object Obj = new Object(); 30 } 31 32 public class Name1 33 { 34 public String Id { get; set; } 35 }