Defining Inheritance

In some situations you create classes that inherit from other classes that are decorated with attributes. Attribute inheritance is not automatic in that you can establish whether your attributes are inheritable. You establish this behavior by setting the Inherited property at AttributeUsage level. By default, if you do not explicitly set Inherited, it is considered as True. The following example shows how you enable attribute inheritance:

'Attribute is also inherited<AttributeUsage(AttributeTargets.Class Or AttributeTargets.Property,                Inherited:=True)>Public Class DocumentPropertiesAttribute

The following snippet shows instead how to make an attribute not inheritable:

Get Visual Basic 2015 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.