如果列表不为null,我可以序列化List。
但是如果这个列表为null,我会在反序列化时获得一个空列表。
当序列化时列表为空时,为了在反序列化时获取null,我该怎么做?
到目前为止,我的尝试是:
[System.Xml.Serialization.XmlArray("WorksButIsNoList", IsNullable = true)]
public MyClass[] WorksButIsNoList { get; set; }
[System.Xml.Serialization.XmlArray("ThrowsException", IsNullable = true)]
public List<MyClass> ThrowsException { get; set; }
[System.Xml.Serialization.XmlElement("IsntNull", IsNullable = true)]
public List<MyClass> IsntNull { get; set; }
[System.Xml.Serialization.XmlElement("ThrowsException2", IsNullable = true)]
public List<int> ThrowsException2 { get; set; }
[System.Xml.Serialization.XmlElement("IsntNull2", IsNullable = true)]
public List<int?> IsntNull2 { get; set; }