受保護的 Friend (Visual Basic)Protected Friend (Visual Basic)

Protected Friend 關鍵字組合是成員存取修飾詞。The Protected Friend keyword combination is a member access modifier. 它會在宣告的元素上授Friend存取和受保護的存取,因此可以從相同元件中的任何位置、從其本身的類別,以及從衍生類別存取。It confers both Friend access and Protected access on the declared elements, so they are accessible from anywhere in the same assembly, from their own class, and from derived classes. 您只能在類別的成員上指定 Protected Friend;您無法將 Protected Friend 套用到結構的成員,因為無法繼承結構。You can specify Protected Friend only on members of classes; you cannot apply Protected Friend to members of a structure because structures cannot be inherited.

注意

在 Visual Studio 中,選取 [F1 說明] [protected friend] 可提供受保護friend的協助。In Visual Studio, selecting F1 help on protected friend provides help for either protected or friend. IDE 會挑選游標下的單一 token,而不是複合字組。The IDE picks the single token under the cursor rather than the compound word.

規則Rules

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

請參閱See also