Xml Serialization - Render Empty Element

前端 未结 5 1446
说谎
说谎 2021-02-07 03:44

I am using the XmlSerializer and have the following property in a class

public string Data { get; set; }

which I need to be output exactly like

5条回答
  •  你的背包
    2021-02-07 04:40

    I was recently doing this and there is an alternative way to do it, that seems a bit simpler. You just need to initialise the value of the property to an empty string then it will create an empty tag as you required;

    Data = string.Empty;
    

提交回复
热议问题