How can I inherit attributes?

  • Thread starter Thread starter Michael
  • Start date Start date
M

Michael

Hi,

I create an abstract baseclass with the attribute [Serializeable].
I want that all classes that inherit thate baseclass also iherhit
[Serializeable].
How can I do that?. It seems to me that I have to write the attribute to
each class manualy.
Tryed in .NET 1.0, 1.1 und 2.0.

Thanks for a fast answere
Michael
 
You can't. MS, when creating that attribute, marked it as not
inheritable. So you'll have to mark each derived class with it if you
want it to be serializable.

Andy
 
Michael said:
Hi,

I create an abstract baseclass with the attribute [Serializeable].
I want that all classes that inherit thate baseclass also iherhit
[Serializeable].
How can I do that?. It seems to me that I have to write the attribute
to each class manualy.
Tryed in .NET 1.0, 1.1 und 2.0.

It makes no sense for [Serializable] to be inheritable. The reason is
that although the base class has fields that are serializable (that's
why the class author added the attribute) the base class author has no
idea whether the derived class will have fields that are serializable.
Thus, the decision as to whether the derived class is serializale is
made by that class's author, and hence [Serializable] is not
automatically inherited.

Richard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top