Domain and properties
In order to save various data information of the instance of the class, C # gives us two ways: domain and properties. Properties achieve good data package and hidden. Domain initialization: For static variables, non-static variables, and array elements, these The variable automatically initials the default value of itself. For all reference type variables, the default value is null. In the class, the initialization of the domain is divided into two types: for static domain, the class is initialized when loading; for non-, in the class During example creation. Before the default initialization, the value of the domain is unpredictable. For example: use system; class test {static int a = b 1; / / must be static variable, otherwise compiling will not pass. Static int INT B = a 1;
Test () {// Constructor does not have a return value, including void console.writeline ("the a = {0}; b = {1};", A, b);}
PUBLIC static void main () {test a = new test ();}}
Unlike the domain, the attribute is not a variable, so the property cannot be passed as a REF or OUT parameter. Static attributes need to be referenced using the type name. The static attribute accessor will be used to make an error