我怎么能忽略使用SharpSerializer序列化的Null属性

时间:2017-01-24 07:01:13

标签: c# xml-serialization deserialization xmlserializer

我正在使用SharpSerializer将对象序列化为XML。默认情况下,所有公共属性都已序列化。

是否可以从序列化中排除空值?

例如:

public class Test
{
   public int Id {get;set;}
   public string Text {get;set;}
}

private void Main(string[] args)
{
   Test t = new Test();
   t.Id = 1; //Serialize this
   t.Text = null; //Don't serialize this

   //Do Serialization
}

0 个答案:

没有答案