ISerializable and backward compatibility

前端 未结 5 1818
我寻月下人不归
我寻月下人不归 2021-01-05 14:30

I have to work an an old application that used binaryFormatter to serialize application data into filestream (say in a file named \"data.oldformat\") without any optimizazio

5条回答
  •  鱼传尺愫
    2021-01-05 15:09

    Just try the same thing you've been doing so far

    BinaryFormatter b = new BinaryFormatter();
    MainClass a = b.DeSerialize(mystream) as MainClass;
    

    Implementing ISerializable didn't change your original class, basically you've just added some methods

提交回复
热议问题