Possible Duplicate:
What's the difference between using the Serializable attribute & implementing ISerializable?
What does tagging a class with Serializable do? e.g.:
[Serializable]
public Hashtable
{
}
How is it different from the class implementing ISerializable? e.g.:
public Hashtable : ISerializable
{
}
And how is that different from tagging the class as Serializable and implementing ISerializable? e.g.:
[Serializable]
public Hashtable : ISerializable
{
}
What is the purpose of [Serializable] as opposed to ISerializable?
tl;dr: What is [Serializable]?
I thought you’d linked to Serializable, but you didn’t:
and,
That is, the
Serializableattribute indicates that this type can be serialized.ISerializableindicates that this type wants to control how this type is serialized.Or, to put it another way, your question is phrased the wrong way around.
SerializableAttributeshould always be applied (to serializable classes), and is the “basic” level of serialization.ISerializableadds more (by allowing you to write code to control the process).