Asp.net modifier introduction (about public, private, protected, internal), protectedinternal
1. private Modifier
The private modifier is used to set the access permission of a class or class member to the internal of the class,
Private is also called a private modifier. You can use the get and set accessors to read or modify private class members.
2. protected Modifier
The protected modifier is used to set the access permissions of a class or class member to the class and its subclass.
3. internal Modifier
The access permission of the class or class member modified by internal modifier is within the same assembly, and the default class access modifier of C # is internal.
4. public Modifier
The public modifier is the public access permission, which has no restrictions on code access,
In most cases, you must exercise caution when using the public modifier because misuse affects the encapsulation of classes and brings security risks.
Declared accessibility Significance
Public access is unrestricted.
Protected access is limited to include classes or types derived from include classes.
Internal access is limited to the current project
Protected internal access is limited to the current project or type derived from the include class
Private access is limited to include type only
Brief Introduction to access permissions of private, protected, public, and internal Modifiers
Private: a private member that can be accessed within the class.
Protected: protects members, which can be accessed within the class and in the inheritance class.
Public: A public member. It is completely public and has no access restrictions.
Internal: accessible within the same namespace.
ASPNET> How do I use protected, internal, and private? Even unclear
Private: members modified by this modifier can only be accessed within the class. Even if an instance of this class is declared elsewhere, members modified by this modifier cannot be accessed.
Protected: members modified by this modifier can be accessed inside the class and the subclass of the current class.
Internal: members modified by this modifier can be accessed in the same namespace.