我正在尝试序列化 DataContract ..... 我想重命名 DataMember。
这是我的数据合同
[DataContract(Name = "Sample")]
[Serializable]
public struct Sample
{
public string CompanyName;
public string AddressLine;
[DataMember(Name="AddressLineRename")]
public string AddressLine2;
public string City;
}
它被序列化为:
<Sample>
<CompanyName>aaa</CompanyName>
<AddressLine>16 aaaa</AddressLine>
<AddressLine2>Unit 66</AddressLine2>
<City>Houston</City>
</Sample>
我需要的是:
<Sample>
<CompanyName>aaa</CompanyName>
<AddressLine>16 aaaa</AddressLine>
<AddressLineRename>Unit 66</AddressLineRename>
<City>Houston</City>
</Sample>
我希望将“AddressLine2”序列化为“AddressLineRename”。
Thanks.