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. Overridable修飾詞允許在衍生類別中覆寫類別中的屬性或方法。The Overridable modifier allows a property or method in a class to be overridden in a derived class. 如需詳細資訊,請參閱繼承的基本概念For more information, see Inheritance Basics.

如果OverridableNotOverridable修飾詞未指定,預設值取決於是否屬性或方法會覆寫基底類別屬性或方法。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.

您只能在屬性或程序宣告陳述式中使用 NotOverridableYou 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或是NotOverridablePrivate方法。You cannot specify Overridable or NotOverridable for a Private method.

您無法指定NotOverridable連同MustOverrideOverridable,或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 陳述式Property Statement

Sub 陳述式Sub Statement

另請參閱See also