【发布时间】:2015-05-13 08:30:17
【问题描述】:
我的班级
public MyClass
{
[DataMemberAttribute(EmitDefaultValue = true)]
public decimal? a { get; set; }
[DataMemberAttribute(EmitDefaultValue = true)]
public DateTime? b { get; set; }
[DataMemberAttribute(EmitDefaultValue = true)]
public int? c { get; set; }
[DataMemberAttribute(EmitDefaultValue = true)]
public bool? d { get; set; }
}
Decimal、DateTime 和 int 可以为空。所以我有:
<MyClass ...>
<a>3</a>
<b i:nil="true"/>
<c i:nil="true"/>
<d i:nil="true"/>
</MyClass>
当 a、b、c 为空时,我想得到这个:
<MyClass ...>
<a>3</a>
<b/>
<c/>
<d/>
</MyClass>
【问题讨论】:
标签: c# asp.net xml-serialization nullable xmlserializer