.NET learning - type, memory, variable

c # program is a set of type declarations.

 

Type is a template

  What types of elements: Name (int); data structure (Bytes); Behavior (16-bit integer)

 

Stack and heap

  Stack: it is a set of memory arrays. You can only be inserted or deleted from the top of the stack. Inserting data stack (push), the data is deleted from the stack (pop). LIFO data structure.

  Heap: It is an area of ​​memory. Heap memory can be inserted or deleted in any order. Pile of data deletion by the CLR GC.

  Note:

    GC process:

      a. Save the heap three objects.

      B. One object is no longer used by the program.

      c.GC found that this object and release it.

      D. The released memory objects can be reused.

 

Value types and reference types

  Value and reference objects in memory different type of storage.

  Value Type: only takes a separate memory. For storing the actual data.

  Reference types: memory needs Sec. The first section to store the actual data. It is always stored on the heap. Second is a reference to the data storage location in the heap.

  Other types of data is not a member of:

    Value Type: data is stored in the stack.

    Reference types: data on the heap, quoted on the stack.

  Data are members of other types:

    Object reference type data is always stored on the heap.

    Type of object reference type or a value of a reference portion according to the actual environment stored in the stack or the stack.

 

Variable: is a name that represents the data stored in memory during program execution.

 

 

 

 

  

Guess you like

Origin www.cnblogs.com/youny/p/11685589.html