1. Scope modifier modifier:
Public: Common access, that is, members of the owning class and members of the non-owning class can access
Private access: Only members of the owning class can access the
Internal: Internal access, only the current assembly can access
Protected: Protected Access, the type of the owning subclass and parent class can be accessed
2. Static variable statics
Static variables do not disappear after the function is executed, and their values are preserved throughout the program.
A static variable can be initialized outside of a member function or a class definition.
For all objects of a class, only one copy of the static variable exists in memory and cannot be instantiated.
Because there is no instance variable, you use the class name itself to access the members of the static class.
You can get the value of a static variable without creating an instance of the class
If you apply the static keyword to a class, all members of the class must be static.
3. Constructor function
Instance constructors: Instance constructors are called when an instance of a class is created. These constructors are used to initialize class data members. Static constructors: Static constructors are used to initialize static variables of a class. These variables are created using the static keyword, and the values they store can be shared by all instances of the class.
C # Fundamentals (ii)