NotOverridable (Visual Basic)NotOverridable (Visual Basic)

指定不能在派生类中重写属性或过程。Specifies that a property or procedure cannot be overridden in a derived class.

备注Remarks

NotOverridable修饰符可防止在派生类中重写属性或方法。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.

如果 Overridable NotOverridable 未指定或修饰符,则默认设置取决于属性或方法是重写基类属性还是替代方法。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. 如果属性或方法重写基类属性或方法,则默认设置为 Overridable ; 否则为 NotOverridableIf 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.

NotOverridable只能在属性或过程声明语句中使用。You can use NotOverridable only in a property or procedure declaration statement. 只能 NotOverridable 在替代另一个属性或过程的属性或过程上指定,即,只能与一起使用 OverridesYou can specify NotOverridable only on a property or procedure that overrides another property or procedure, that is, only in combination with Overrides.

组合修饰符Combined Modifiers

不能 Overridable NotOverridable 为方法指定或 PrivateYou cannot specify Overridable or NotOverridable for a Private method.

不能 NotOverridable MustOverride Overridable Shared 在同一声明中同时指定、或。You cannot specify NotOverridable together with MustOverride, Overridable, or Shared in the same declaration.

用法Usage

NotOverridable 修饰符可用于下面的上下文中:The NotOverridable modifier can be used in these contexts:

Function 语句Function Statement

Property StatementProperty Statement

Sub 语句Sub Statement

另请参阅See also