本文介绍了什么是[Serializable]属性做了ISerializable不?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 可能重复:   What's使用Serializable属性与放大器之间的差异;实现了ISerializable? 这是什么标记一个类与 序列化 吗?例如:What does tagging a class with Serializable do? e.g.:[Serializable]public Hashtable {}它是如何从类不同实现 ISerializable的 ?例如:How is it different from the class implementing ISerializable? e.g.:public Hashtable : ISerializable{}又是怎样的是的从标签中的类为序列化和实施 ISerializable的 的?例如:And how is that different from tagging the class as Serializable and implementing ISerializable? e.g.:[Serializable]public Hashtable : ISerializable{} 的目的是什么[Serializable接口] ,而不是 ISerializable的? TL;博士:什么是 [Serializable接口] 推荐答案我还以为你挂的序列化,但你没有:I thought you'd linked to Serializable, but you didn't:这是打上了 SerializableAttribute 默认情况下序列化,除非该类型实现了 ISerializable的界面重写序列化进程。 All the public and private fields in a type that are marked by the SerializableAttribute are serialized by default, unless the type implements the ISerializable interface to override the serialization process. 和应用,即使该类还实现了 ISerializable的接口 SerializableAttribute 属性[...] Apply the SerializableAttribute attribute even if the class also implements the ISerializable interface [...]也就是说,序列化属性表明这种类型的可以的序列化。 ISerializable的表示,这种想控制的如何的这种类型的序列化。That is, the Serializable attribute indicates that this type can be serialized. ISerializable indicates that this type wants to control how this type is serialized.或者,换一种说法,你的问题是围绕措辞错误的方法。 SerializableAttribute 应的总是的应用(以序列化类),并且是系列化的基本的水平。 ISerializable的添加更多(允许你写code控制过程)。Or, to put it another way, your question is phrased the wrong way around. SerializableAttribute should always be applied (to serializable classes), and is the "basic" level of serialization. ISerializable adds more (by allowing you to write code to control the process). 这篇关于什么是[Serializable]属性做了ISerializable不?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-24 03:56