Property accessors cannot be declared '<accessmodifier>' in a 'NotOverridable' property

A Get Statement or Set Statement (Visual Basic) in a NotOverridable property includes the Private keyword.

The following line of reasoning explains why NotOverridable and Private cannot be combined in a Property Statement:

  1. A property or procedure that does not override a base class property or procedure has a default setting of NotOverridable.

  2. However, a property or procedure in a derived class that overrides a base class property or procedure has a default setting of Overridable. To terminate the hierarchy of overriding, you can declare it NotOverridable. This is the only context in which you can use NotOverridable. That is, you can use NotOverridable only in combination with Overrides.

  3. If a base class property or procedure is declared Private (Visual Basic), a derived class cannot override that property or procedure because it cannot access it. Because of this, you cannot use Private in combination with Overridable.

  4. To override a property or procedure, the overriding property or procedure must have not only the identical signature but also the same access level. This means that an overriding property or procedure cannot specify Private, because an overridable property or procedure cannot specify Private.

  5. Because you can specify NotOverridable only on an overriding property or procedure, you cannot combine it with Private.

By the same reasoning, the individual property procedures (Get and Set) of an overriding property cannot be Private.

Error ID: BC31106

To correct this error

  • Remove the Private keyword from the Get or Set statement, or remove the Overrides and NotOverridable keywords from the Property statement.

See Also

Tasks

How to: Declare a Property with Mixed Access Levels

Concepts

Property Procedures

Differences Between Shadowing and Overriding