存取修飾詞 (C# 參考)Access Modifiers (C# Reference)

存取修飾詞是用來指定成員或類型的宣告存取範圍的關鍵字。Access modifiers are keywords used to specify the declared accessibility of a member or a type. 本節將介紹四種存取修飾詞:This section introduces the four access modifiers:

  • public
  • protected
  • internal
  • private

您可以使用存取修飾詞,指定下列六個存取層級:The following six accessibility levels can be specified using the access modifiers:

  • public:未限制存取。public: Access is not restricted.

  • protected:存取限於包含類別或衍生自包含類別的類型。protected: Access is limited to the containing class or types derived from the containing class.

  • internal:存取限於目前組件。internal: Access is limited to the current assembly.

  • protected internal:存取限於目前組件或衍生自包含類別的類型。protected internal: Access is limited to the current assembly or types derived from the containing class.

  • private:存取限於包含類型。private: Access is limited to the containing type.

  • private protected:存取限於目前組件內包含類別或衍生自包含類別的類型。private protected: Access is limited to the containing class or types derived from the containing class within the current assembly.

本節也會介紹下列項目:This section also introduces the following:

另請參閱See also