A static constructor is a new feature of C #, which seems to be seldom used. But we need to use it when we want to initialize some static variables.This constructor belongs to the class.,Rather than where the instance belongs., which means that this constructor
will only be executed once。 That is, creating
first oneAutomatically called by. NET before an instance or any static member is referenced.
Class simpleclass{ //static constructor static Simpleclass () { // }}
There are a few things to keep in mind when using static constructors:
(1), static constructors have neither access modifiers nor parameters. Because it is. NET calls, so modifiers like public and private are meaningless.
(2), when the first class instance is created or any static member is referenced. NET will automatically call the static constructor to initialize the class, which means that we cannot call the static constructor directly, and we cannot control when the static constructor is executed.
(3), a class can have only one static constructor.
(4), parameterless constructors can coexist with static constructors. Although the parameter list is the same, one belongs to the class and one belongs to the instance, so there is no conflict.
(5), run at most once.
(6), static constructors cannot be inherited.
(7), if a static constructor is not written, and the class contains a static member with an initial value set, the compiler automatically generates a default static constructor. 7. When invoking a base class constructor with parameters, use the base keyword. C # Reference method parameter keywords: params, ref and Out (http://www.cnblogs.com/hunts/archive/2007/01/13/619620.html) 8, (1), Structs and Arrays: structs can have members of different data types, and members of a struct can define their own access rights. (2), sets and arrays: In the case of determining the number of data, an array can be used to store processing data. However, the number of data is not certain, you can use the collection, the program run time to dynamically change the storage length, add or delete elements (approximately think of the set is a dynamic array). (3), the array of clone and Copyto:1) CopyTo the target array must be instantiated, clone does not need, 2) CopyTo need to set the starting position, clone does not need. (4), array class and ArrayList class;
C # Learning Essays