How to exclude null properties when using XmlSerializer

前端 未结 9 1573
谎友^
谎友^ 2021-02-02 07:11

I\'m serializing a class like this

public MyClass
{
    public int? a { get; set; }
    public int? b { get; set; }
    public int? c { get; set; }
}
         


        
9条回答
  •  名媛妹妹
    2021-02-02 07:54

    Mark the element with [XmlElement("elementName", IsNullable = false)] null values will be omitted.

提交回复
热议问题