In C#programming, you may already use the
access modification character, but the functions of other access modifiers may not know much about it. This article will explore the access modifications in C#, explain the differences between, public
, public
and the non -access modification statement statement in detail, and clarify the mysterious private
modification and its characteristics. protected
static
Access modifier: Define the boundary of access permissions
The visibility and accessability of the device control class, methods and variables in the program. C#provides a variety of access modifications:
:
public
: The most stringent access modification format is limited to internal access to the class of the entity. private
Semi -private modifier, allows access to the claim, derivatives and the same sequence set.
protected
internal
private protected
protected
The modifier is a powerful tool that gives the unique attributes: instantiated:
Static classes cannot be instantiated as non -static classes. You will not see the familiar keywords for creating static class instances.Member: All members of the static class are static, which means that no matter how many objects are created, each member has only one version.
Construct function: static
Static classes can have a static constructor. Before creating any instance or reference to static members, the static constructor will be automatically called.
new
Static class is usually used as a service provider, providing convenient functions without the need to create an instance burden. The above is the detailed content of What are Access Modifiers and the Static Modifier in C#, and How Do They Work?. For more information, please follow other related articles on the PHP Chinese website!