My .Net fairy tale five

xiaoxiao2021-03-06  70

C # Syntax and C are very similar, so from C turn over, it is not difficult.

But pay attention to a few points:

One,

Value Type: Simple Type, Structure Type, Enumeration Type.

The variable itself and its saved data are in the stack.

Quote type: class, representative, array, interface.

The reference type variable contains references to objects or data allocated on the heap.

two,

For boxing, if the original value of the variable is modified, then the copy on the pile does not change because it is just a copy.

During unboxing, the translatable type must be accurately matched to the data type in Box. For example, from int to long, there is a built-in implicit conversion from INT to LONG, but it is not applicable. Match must be accurate.

three,

If a readonly modifier is used for a member variable, it can only be assigned when the class or object is initialized (can be directly in the declaration, or in the constructor).

When the specific value is not determined in the compilation, it is not suitable for use with the const keyword. At this time, the readonly modifier can be used.

four,

When there is a plurality of construct functions, the initial value setting item can be specified by using the keyword THIS.

When the keyword tris is added to the constructor declaration, the constructor that matches the specific parameter list will call the provincial constructor when the parameter list is empty.

Fives,

The static constructor can be presented to the initialization class itself. The static constructor is created before the first instance of the class, or before using any static method used, and executes up to once.

six,

Params: The compiler will call the method with parames parameters and create an array and pass this array to the method.

note:

Params keyword can only be modified in one-dimensional array. You cannot overload the method only based on params keywords. Ref or OUT keywords are not allowed to use the params array. Params arrays must be the last parameter. Type conversion rules apply to Params arrays. The compiler can reject overloaded with potentially unity. The method without using the params array is always higher than the method of using the params array.

转载请注明原文地址:https://www.9cbs.com/read-119513.html

New Post(0)