Why we need not to declare a serialVersionUID(or equivalent) in C#?

大憨熊 提交于 2019-12-23 09:16:50

问题


In Java it is strongly recommended that all serializable classes explicitly declare serialVersionUID since the default serialVersionUID computation is highly sensitive to class details and compiler implementation is unreliable.

What's so special about serialization in C#?


回答1:


In .Net Serialization is less cranky than in Java.

By default it supports new fields just defaulting them, and it just ignore any data it doesn't expect.

You can still implement the same kind of version control by implementing the ISerializable interface in your class and adding your own custom VersionId to your class and check it there.

You can read more about this here



来源:https://stackoverflow.com/questions/30185315/why-we-need-not-to-declare-a-serialversionuidor-equivalent-in-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!