XML serialization of list

后端 未结 2 1702
無奈伤痛
無奈伤痛 2020-12-19 09:04

I am serializing an object to XML. I have something like this:

Class A
{
   public string propertyA1  { get; set; }
   public List bList { get; set         


        
2条回答
  •  不知归路
    2020-12-19 09:48

    Add the attribute [XmlElement] to treat the collection as a flat list of elements:

    Class A
    {
       public string propertyA1  { get; set; }
       [XmlElement("B")]
       public List bList { get; set; }
    }
    

    for more info click here

提交回复
热议问题