如果任何域对象,而不是可序列化的?而不是、对象、序列化

2023-09-07 04:53:16 作者:乜許。迩吥嬞

有没有办法,只是告诉编译器,我想我的对象是序列化的默认?

Is there a way to just tell the compiler, that I want my objects to be serializable by default?

推荐答案

pretty的每得多序列化引擎会想知道你的对象是合适的。这可以采取以下形式:

Pretty much every serialization engine is going to want to know that your objects are suitable. This can take the form of:

[Serializable接口] / ISerializable的(BinaryFormatter的 , SoapFormatter [Serializable接口] / 的IXmlSerializable (和公开 )(的XmlSerializer [DataContract] / [MessageContract] (或最上面)( DataContractSerializer的及变种) [Serializable]/ISerializable (BinaryFormatter,SoapFormatter) [Serializable]/IXmlSerializable (and public) (XmlSerializer) [DataContract]/[MessageContract] (or most of the above) (DataContractSerializer and variants)

AFAIK,没有办法避免这种步骤的

AFAIK, there is no way of avoiding this step.