I think everyone knows this four modifiers very well, but here I still want to say, why? Because each person has different understandings of it, I wrote a story about myself and shared it with everyone. I hope you can point out something wrong or something you need to talk about.
C # Class and Class Member modifiers include the following five:
Public Class and Class Member modifiers have no level limit on access members
Modifier of private class members can only be accessed within the class
The modifier of protected class members can only be accessed in the class and its derived classes, regardless of whether the derived class and the base class are in the same assembly
Accesses to internal classes and class member modifiers within internal are limited
What does protected internal mean internally protected? Note: If the diagram shows an inherited link, it can be accessed in the same set of programs or not. If it is not an inherited link, it can only be accessed in the same set of programs.
Class access permissions:
Only public and internal modifiers can be placed before the class. If no modifier is written, the default modifier is internal.
Let's first talk about the class access permission: 1: public class: This class can be accessed anywhere; 2: internal class: only in the same assembly (you can understand it as follows: if you have created a solution with three projects, there will be three sets. If you set a class in the first project to internal class, therefore, it is impossible for the second project to call this class because it is not in the same assembly.) This class can be accessed;
Access Permissions of class members:
The access permissions of class members can be composed of four modifiers: public, private, protected, internal, and protected internal. If no modifier is written before class members, the default value is private.
I found a picture on the Internet for their access permissions. I posted this picture, which shows the access permissions of class members.
This article from the CSDN blog, reproduced please indicate the source: http://blog.csdn.net/menglin2010/archive/2010/12/04/6054483.aspx