## 規則Rules

• 宣告內容。Declaration Context. 您可以使用Shadows只能在類別層級。You can use Shadows only at class level. 這表示的宣告內容Shadows項目必須是類別，，而且不能是原始程式檔、 命名空間、 介面、 模組、 結構或程序。This means the declaration context for a Shadows element must be a class, and cannot be a source file, namespace, interface, module, structure, or procedure.

您可以宣告一個宣告陳述式中只能有一個遮蔽的項目。You can declare only one shadowing element in a single declaration statement.

• 結合的修飾詞。Combined Modifiers. 您無法指定Shadows連同OverloadsOverrides，或Static相同宣告中。You cannot specify Shadows together with Overloads, Overrides, or Static in the same declaration.

• 項目型別。Element Types. 您可以使用任何其他類型遮蔽任何一種已宣告的項目。You can shadow any kind of declared element with any other kind. 如果您遮蔽的屬性或程序與另一個屬性或程序，參數和傳回型別沒有以符合那些在基底類別屬性或程序。If you shadow a property or procedure with another property or procedure, the parameters and the return type do not have to match those in the base class property or procedure.

• 存取。Accessing. 無法從遮蔽的衍生類別內通常使用遮蔽基底類別中的項目。The shadowed element in the base class is normally unavailable from within the derived class that shadows it. 不過，適用下列考量。However, the following considerations apply.

• 如果遮蔽的項目不能從參考它的程式碼存取，則參考會解析為遮蔽的項目中。If the shadowing element is not accessible from the code referring to it, the reference is resolved to the shadowed element. 例如，如果Private項目會遮蔽基底類別的項目，並沒有存取權限的程式碼Private項目改為存取基底類別項目。For example, if a Private element shadows a base class element, code that does not have permission to access the Private element accesses the base class element instead.

• 如果遮蔽的項目時，您仍然可以透過使用基底類別的型別宣告的物件存取遮蔽的項目。If you shadow an element, you can still access the shadowed element through an object declared with the type of the base class. 您也可以存取透過MyBaseYou can also access it through MyBase.

Shadows 修飾詞可用於以下內容：The Shadows modifier can be used in these contexts: