第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何讓protubuf-net在反序列化時不考慮默認數(shù)組值

如何讓protubuf-net在反序列化時不考慮默認數(shù)組值

C#
qq_笑_17 2021-09-19 16:17:29
嘗試這個:static class Program{    /// <summary>    /// The main entry point for the application.    /// </summary>    [STAThread]    static void Main()    {        Application.EnableVisualStyles();        Application.SetCompatibleTextRenderingDefault(false);        var f = new Form1();        f.Mode = false;        Application.Run(f);        bool playerMode = f.Mode;    }}和:public partial class Form1 : Form{    public Form1()    {        InitializeComponent();    }    public bool Mode = false;    private void button1_Click(object sender, EventArgs e)    {        this.Mode = true;        this.Close();    }    private void button2_Click(object sender, EventArgs e)    {        this.Mode = false;        this.Close();    }}這對我bool playerMode根據(jù)我單擊的按鈕進行設(shè)置很好用。
查看完整描述

1 回答

?
qq_遁去的一_1

TA貢獻1725條經(jīng)驗 獲得超8個贊

這里的問題是 protobuf-net 通過附加數(shù)據(jù)來反序列化列表(等)數(shù)據(jù)。


解決方案是將列表初始化從 ctor 移動到具有設(shè)置屬性 SkipConstructor=true 的構(gòu)造函數(shù)。


[ProtoContract(SkipConstructor=true)]

public class Data

{

    [ProtoMember(1)]

    public bool[] Flags;


    public Data()

    {

        Falgs = new bool[3] { true, true, true }

    }

}


查看完整回答
反對 回復(fù) 2021-09-19
  • 1 回答
  • 0 關(guān)注
  • 199 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號