About static functions and static variables in C# classes

        When we declare a class member as static, it means that no matter how many objects of the class are created, there will only be one copy of the static member. The keyword  static  means that there is only one instance of the member in the class. It can be understood that each object shares a variable for this type of object

         C# static methods belong to the class and can be used before the class is instantiated. Static methods can only access static members of the class. When using a non-static method, you must first instantiate an object, and then use this method. The non-static method can access any member in the class. (The non-static member is before the class is instantiated. The system does not allocate memory. Therefore, it cannot be called)

         Some are summarized by others

 

 

 

Guess you like

Origin blog.csdn.net/zkx0214/article/details/126981858