Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Use access modifiers to specify the declared accessibility of a member or a type. This section introduces the four access modifiers:
publicprotectedinternalprivate
By using these access modifiers, you can specify the following six accessibility levels:
public: No access restrictions.protected: Access is limited to the containing class or types derived from the containing class.internal: Access is limited to the current assembly.protected internal: Access is limited to the current assembly or types derived from the containing class.private: Access is limited to the containing type.private protected: Access is limited to the containing class or types derived from the containing class within the current assembly.
In addition, a top-level (non-nested) type can use the file modifier. The declared type is only visible in the current source file. File scoped types are generally used for source generators. You can't combine the file modifier with any access modifier.
This section also introduces the following concepts:
- Accessibility Levels: Using the access modifiers to declare levels of accessibility.
- Accessibility Domain: Specifies where, in the program sections, a member can be referenced.
- Restrictions on Using Accessibility Levels: A summary of the restrictions on using declared accessibility levels.