How to quickly save/load class instance to file

后端 未结 7 1473
终归单人心
终归单人心 2020-12-09 05:33

I have several collections of classes/structs in my app.

The class is just a class with fields

class A
{
  public int somevalue;
  public string some         


        
7条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-09 06:10

    I usually use the XML Serilizer, is fast, easy to implement and keep the objects in a hummand readable fashion, you can see a nice example.

    You can use a binary serialization if you want a more size effective obfustated solution. (for example if you want to transmit the serialization over a network.)

    EDIT: To get more control over the elements you serialize take a look of this example

提交回复
热议问题