C#中static类型的变量和方法
Variables and methods of type C# in static
define variables and methods, and do not know when to add and the concept of object, it is only the class itself of this concept, and it is the object belongs to the two mutual demolition of the state, that is I without you, without you in my situation. That is, you use object names, static variables, or object names. Static methods are not accessible.
each class must have a constructor, otherwise this class cannot be instantiated into an object. And we sometimes define classes that do not write their constructors, because the compiler adds a static null constructor to us. This can be instantiated. Static constructors can also be used to initialize static variables.
The full use of static
To understand static, you must first understand one another and the relative words, many people may not know the key, that is auto, in fact, we do not usually statement static modified variable is auto, because it is the default, like short and long int as the default is always we usually declare a variable:
Int a;
String s:
In fact:
Auto int a;
Auto string s:
And the declaration of the static variable is:
Static int a;
Static string s:
This seems to be more conducive to understanding that auto and static are a pair of keywords, like private, protected, and public;
To understand static, in fact is to don't understand a
C#中static类型的变量和方法 来自淘豆网www.taodocs.com转载请标明出处.