Modifier
The private modifier is used to set the access permissions of a class or class member to only the internal class to which it belongs.
private is also known as a private modifier. When you need to access private class members, you can read or modify them through get and set accessors.
Modifier
The protected modifier is used to set the access permissions of a class or class member to be only inside the class and subclass.
Modifier
The access rights of the class or class member modified by the internal modifier are inside the same assembly, and the default class access modifier of C# is internal.
Modifier
The public modifier is public access permissions and has no restrictions on access to the code.
In most cases, public modifiers must be used with caution, as abuse will affect the encapsulation of the class and bring about security risks.
Accessibility of statements Meaning
Public access is not restricted
protected access is limited to include classes or types derived from include classes
Internal access is limited to the current project only
protected internal access is limited to the current project or type derived from the containing class
private access is limited to include types only