访问修饰符(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