The default access decoration in the c#
In C#, the default access modifier of various program elements depends on its context.
Decided by default access to the modifier:
class, method, member, structure function:
private
internal
public
Elements can only be accessed within their class or structures.
private
internal
Reason: The default access to the modifier ensures that the access permissions are the most restricted by default to protect the integrity of the code and the enforcement of the packaging. This mandatory developer shows a wider range of access permissions when necessary, thereby improving code security. Standard specifications:
According to the C# 3.0 specification (Section 3.5.1):
"When the member statement does not include any access to the modifier, the context that the statement occurs determines the accessability of the default statement."
The above is the detailed content of What are the Default Access Modifiers for Classes, Methods, and Other Members in C#?. For more information, please follow other related articles on the PHP Chinese website!