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

后端 未结 4 1743
旧巷少年郎
旧巷少年郎 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:37

    Don't use Auto-Implemented Properties if you need a null there. use e.g.

    public class MySerializableClass 
    { 
        List myList 
        public List MyList { get {return myList;} set {myList = value;} } 
    } 
    

提交回复
热议问题