Is there a way to avoid the XmlSerializer to not initialize a null property when deserializing?

后端 未结 4 1744
旧巷少年郎
旧巷少年郎 2020-12-16 18:00

I have this class:

public class MySerializableClass
{
    public List MyList { get; set; }
}

If MyList is null when MySeria

4条回答
  •  攒了一身酷
    2020-12-16 18:45

    I had the same problem but adding the XmlArrayAttribute to the property with nothing set made it work for me

    public class MySerializableClass
    {
        [XmlArray]
        public List MyList { get; set; }
    }
    

提交回复
热议问题