Representing Null values differently when serializing objects to XML

前端 未结 2 854
深忆病人
深忆病人 2021-01-22 21:50

I am serializing objects to XML like so using the following code:

using System.IO;
using System.Xml.Serialization;

namespace ConsoleApplication2
{
    class Pro         


        
相关标签:
2条回答
  • 2021-01-22 22:04

    I believe the person in this article has the same problem? Maybe it can provide a solution for you?

    C# xml serialization

    0 讨论(0)
  • 2021-01-22 22:14

    Using

    [XmlElement(IsNullable = true)]
    public string Two { get; set; }
    

    you can represent it as <Two xsi:nil="true" />

    0 讨论(0)
提交回复
热议问题