Are attributes inherited?

D

Dan Holmes

For instance if i inherit from Exception

public class MyException : Exception
{
public String myVar ;
public MyException (String myVar, String message) : base(message)
{
this.myVar = myVar;
}
}

When this is serialized do i need to write a GetObjectData or add the
[Serializable] attribute? Or is that handled because the base class does?

I want myVar populated when the object is deserialized.

dan
 
C

Chris Fulstow

Hi Dan,

The Serializable attribute can't be inherited. If you derive a new
class then it must also be marked with the attribute as well, or it
cannot be serialized.

HTH,

Chris
 

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

Top