Private, protected, public, and internal
Private, protected, public, and internal
PrivateIt is completely private and can only be called in the class itself. It cannot be called outside the class or subclass, or inherit the private attributes and methods of the parent class.
ProtectedAlthough it can be seen by the outside world, it cannot be called by the outside world. It can be called only by itself and its own subclass (the attributes and methods of protected can be inherited and called by the quilt class ).
What private and protected have in common: No external access is allowed.
Differences between private and protected: The same class can be considered the same, but it is different in inheritance. Private cannot be accessed in a derived class, while protected can.
PublicAll classes and members are publicly available without restrictions.
InternalSame ApplicationProgramSet (in a project in vs. net, the project here refers to a separate project, rather than the entire solution) can be accessed.
Differences between public and internal: Public members can cross-assembly, but internal cannot. The same Assembly has the same effect.
Protected internal:Only this class and derived class can be accessed in the same application assembly.