c# XML Serialization How to serialize flat list with xsi:nil="true"

When serializing a flat List (ie with XmlElement-Attribute) and IsNullable=true, the output doesn't have the xsi:nil="true" entry if the List is null.

 [System.Xml.Serialization.XmlElement(IsNullable = true)]
public List<OrdinanceValueType> ordinance
{
    get
    {
        return this.ordinanceField;
    }
    set
    {
        this.ordinanceField = value;
    }
}

With XmlArray-Attribute, it works, but the list isn't flat anymore.

Is there a way to get xsi:nil="true" with a flat list?

链接地址: http://www.djcxy.com/p/65144.html

上一篇: 在WCF请求中强制使用DefaultValueAttribute的属性序列化

下一篇: c#XML序列化如何使用xsi序列化平面列表:nil =“true”