C#對象序列化失敗解決方案(很牛逼)

來源:互聯網
上載者:User

標籤:對象   c#   序列化   

C#序列化非常方便。只需定義類型即可。但是有時也會遇到奇葩問題。你是否遇到下面這樣的問題


這種問題困擾了我很久。最後終於解決了。方法真的想不到!

廢話少說。看看如何解決?

上代碼:

using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Runtime.Serialization;namespace WeChat.BLL.ClassModel.EmployeeModel{    [DataContract(Name = "attrs", Namespace = "http://schames.menglin.net/2012/05/08")]    public class AttachInfo    {        [DataMember(Name = "name", IsRequired = true, Order = 0)]        public string name { get; set; } //名稱        [DataMember(Name = "value", IsRequired = true, Order = 1)]        public string value { get; set; }//值        //建立建構函式        public AttachInfo(string name, string value)         {            this.name = name;            this.value = value;         }    }}
看到和普通類的區別了麼。

OK。希望能夠協助到你

C#對象序列化失敗解決方案(很牛逼)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.