Question about serialization w/ class inheritence.

  • Thread starter Thread starter Hasani
  • Start date Start date
H

Hasani

If I have a base class that is derived from many classes, and I want to make
all the classes serializable. Is there a way I can do this from the base
class or must I add [Serializable()] to every class, even if it's parent
class has the [Serializable()] attribute.
I'm thinking no from what I've seen on google so far.
 
Hasani,
As you are finding each serializable class needs the Serializable attribute,
even when derived from classes that already have the Serializable attribute.

In case you don't have them the following MSDN Magazine articles are useful
for understanding Serialization.

http://msdn.microsoft.com/msdnmag/issues/02/04/net/
http://msdn.microsoft.com/msdnmag/issues/02/07/net/
http://msdn.microsoft.com/msdnmag/issues/02/09/net/

Binary serialization is going to use less space then SOAP Serialization.
SOAP serialization is really intended for Web Services (SOAP). There is also
XML serialization which is not tied directly to SOAP Serialization, however
you get a similar result.

Hope this helps
Jay
 
Good Find
Thx
Jay B. Harlow said:
Hasani,
As you are finding each serializable class needs the Serializable attribute,
even when derived from classes that already have the Serializable attribute.

In case you don't have them the following MSDN Magazine articles are useful
for understanding Serialization.

http://msdn.microsoft.com/msdnmag/issues/02/04/net/
http://msdn.microsoft.com/msdnmag/issues/02/07/net/
http://msdn.microsoft.com/msdnmag/issues/02/09/net/

Binary serialization is going to use less space then SOAP Serialization.
SOAP serialization is really intended for Web Services (SOAP). There is also
XML serialization which is not tied directly to SOAP Serialization, however
you get a similar result.

Hope this helps
Jay


Hasani said:
If I have a base class that is derived from many classes, and I want to make
all the classes serializable. Is there a way I can do this from the base
class or must I add [Serializable()] to every class, even if it's parent
class has the [Serializable()] attribute.
I'm thinking no from what I've seen on google so far.
 
Back
Top