我正在使用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
}