class test
    {
        public string a;
       public int b;
        public byte[] c;
        public IntPtr d;
    }

把上面对象序列化成string并保存。

  test t=new test() { a = "aa", b = 444, c = new byte[] { 2, 1, 23,200,11,32,3,4,43,23,7 }, d = (IntPtr) 50 };
 string m = Newtonsoft.Json.JsonConvert.SerializeObject(t);

 

如果test对象的成员发生更改,则反序列化时,新增的成员默认为null,已删除的成员不处理,整个程序不会报错。

如类改成:

    class test
    {
        public string tt;
        public string a;
       // public int b;
        public byte[] c;
        public IntPtr d;
    }

相关文章:

  • 2021-06-12
猜你喜欢
  • 2021-08-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-01
  • 2021-06-11
  • 2022-12-23
相关资源
相似解决方案