[英]c# serialize xml custom attributes
當我將類對象序列化為xml時。 屬性會被保存,但屬性不會被保存。 還有什么方法可以序列化/反序列化它們的屬性?
以下是示例:
[Category("Invoice Fare(Selling Price) / Client Fare PP")]
[Description("Client Tax / Tax PP")]
[DisplayName("Client Tax / Tax PP")]
[Browsable(true)]
[RadSortOrder(5)]
public string clientTax { get; set; }
像上面的例子可能像下面
<clientTax Category='xxx' Description='aaa'></clientTax>
要序列化為XML屬性,您需要創建一個類,其中的屬性將是用[XmlAttribute]
批注修飾的XML屬性。
為了重現您的示例,它看起來像這樣:
public class ClientTax
{
[XmlAttribute]
public string Category { get; set; }
[XmlAttribute]
public string Description { get; set; }
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.