Rediģēt

Kopīgot, izmantojot


NotOverridable (Visual Basic)

Specifies that a property or procedure cannot be overridden in a derived class.

Remarks

The NotOverridable modifier prevents a property or method from being overridden in a derived class. The Overridable modifier allows a property or method in a class to be overridden in a derived class. For more information, see Inheritance Basics.

If the Overridable or NotOverridable modifier is not specified, the default setting depends on whether the property or method overrides a base class property or method. If the property or method overrides a base class property or method, the default setting is Overridable; otherwise, it is NotOverridable.

An element that cannot be overridden is sometimes called a sealed element.

You can use NotOverridable only in a property or procedure declaration statement. You can specify NotOverridable only on a property or procedure that overrides another property or procedure, that is, only in combination with Overrides.

Combined Modifiers

You cannot specify Overridable or NotOverridable for a Private method.

You cannot specify NotOverridable together with MustOverride, Overridable, or Shared in the same declaration.

Usage

The NotOverridable modifier can be used in these contexts:

Function Statement

Property Statement

Sub Statement

See also