C # Serialization / Inheritance

Possible duplicate:
Serializable Inheritance

Is serialization inherited?

Example:

[Serializable]
class A
{
}

class B : A
{
}

If I try to serialize / deserialize an instance of class B, I get an exception stating that the class is not marked as serializable. So the question is: is inheritance serialized? I just skipped how to do this, or does each class that needs to be serialized needs to be explicitly labeled as such?

+5
source share
1 answer

This is not inherited :

, Serializable . MyObject, .

, :

[Serializable]
class B : A  {  } 
+11

All Articles