How do I deserialize into an existing object - C#

后端 未结 4 1821
礼貌的吻别
礼貌的吻别 2020-12-18 23:42

In C#, after serializing an object to a file how would I deserialize the file back into an existing object without creating a new object?

All the examples I can fin

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-18 23:52

    If it's just a matter of copying a few fields, I would avoid all the trouble and take the simple route - deserialize into a new instance, then copy the appropriate fields to the existing instance. It will cost you a couple of extra copies, but you'll save a lot of time on debugging.

提交回复
热议问题