I guess I was surprised to learn that Implements or <Serializable()> do not get inherited from class to class which means that it must be redefined each I want to recreated those behaviors. I was wondering what else isn’t inhertible in .Net? Thanks
I guess I was surprised to learn that Implements or <Serializable()> do not get
Share
These are 2 different items: interface and attribute inheritance.
The
Inheritsportion refers to how interfaces behave across class hierarchies. Interfaces are indeed inherited. If a given base class implementsIFactorythen all of it’s derived types will. There are certain language oddities on how a derived class can re-implement the interface or specific methods. However at a .Net level once a base class implements an interface all derived classes will as well.Whether or not an attribute is inherited depends on the value of
AttributeUsage.Inheritedon theAttributeUsagefor the given attribute. In the case ofSerializableit’s marked asInherits=falseand won’t be inherited. Every attribute must pick their own behavior here.