Read "C # primer" notes 1

zhaozj2021-02-16  62

The project finally reported, cool!

I also finally calm down and see the book. Although the development language of the entire project is done with C #, I always feel that the C # foundation is not very firm, so I have to borrow a Stanley for a colleague.

B.Lipppan, Waitcuit Teacher and Chen Shui translated this "C # Primer Chinese version", I plan to make some basic things to understand.

Chapter 1 Hello, C # study notes

1. Alias ​​uses the USING instruction into a (live all) multiple-defined entities tap the name. Alias ​​(alias) is only effective in the current statement space1; use point2d = namespace1.point;

2, local object (local object) Local Object is preferred to assign an initial value Local Object after definition. One name is used in some local living space (Local Scope), then if you try to change the meaning of both names (example

If a new declaration introduced to this name) can cause errors. Class's members declared a statement of the order.

3, data type C # built-in type type byte number explanation BYTE 1 unsigned byte SBYTE 1 Has symbol byte Short 2 Symbol Shorttertort USHORT 2 No symbol Short-character INT 4 Has Symbol Integer UINT 4 No symbol integer Long 8 Symbol long integer ULONG 8 unsigned long integer FLOAT 4 floating point Double 8 double precision number decimal 8 fixed precision String Unicode string type Char Unicode Character type BOOL Boolean User definition type : Class Type (CLASS) Structure Type (STRUCT) Interface Type (Interface)

Data types of memory allocation forms are divided into two types:

Value Types Reference Type (Reference Types)

Value type: Value type data allocates in the stack. They include: all basic or built-in types (excluding String types), structural types, enumeration types (Enum Type)

Quote Type: The reference type is allocated in the heap, which will be collected by garbage when they are no longer used. They use new operators to create, for these types, do not exist of the DELETE operator in C , and simply different from C explicitly use the delete this type of operation to release the created. In C #, these types are automatically collected by the garbage collector. The reference type includes: class type, interface type, set type type, string type, enumeration type

4, packing and unpacking ※ packing

(1), allocated an Object Box in the Managed Head (a piece of space), ready to hold the value object value; (2), copy the value object value to the box; (3), put the box The "Managed Head" address gives Object Object, complete the box; (4), using the packaged value type can result in a decrease in performance.

※ After the box (1), the value type is filled, we cannot access any member of the original type (including attributes and methods); (2), only the reference type data needs to be removed

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

New Post(0)