在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
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 }
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论