. Net divides data types into value type and reference type)
A data with value type is stored in a variable in the stack. That is, allocate memory space in the stack and store the included values directly. The values represent the data itself. Data of the value type has a fast access speed.
A data with reference type does not reside in the stack, but is stored in the heap. That is, allocate memory space in the heap. Instead of directly storing the contained values, it points to the value to be stored. The value indicates the address to which it points. When accessing a data with reference type, you need to check the content of the variable in the stack. The variable references an actual data in the heap. Data of the reference type has a larger storage scale and a lower access speed.
Value Type
(1) Where is this type allocated? Allocated on Stack
(2) How are variables represented? The value type variable is local replication.
(3) What is the base type? Must inherit from system. valuetype
(4) can this type be used as the base class of other types? No. The value type is sealed and cannot be inherited.
(5) What is the default parameter transfer? Variable is passed by value (that is, a copy of the variable is passed into the called function)
(6) can this type rewrite system. Object. Finalize. The value type cannot be placed on the stack, so it does not need to be terminated.
(7) Can I define constructors for this type? Yes, but the default constructor is retained (that is, the User-Defined constructor must have all parameters)
(8) When will this type of variable die? When they reach a defined scope
Cited type
(1) Where is this type allocated?
Allocated on managed stacks
(2) How are variables represented?
The reference type variable points to the memory occupied by the allocated instance.
(3) What is the base type?
It can inherit from any type except system. valuetype, as long as the type is not sealed's
(4) can this type be used as the base class of other types?
Yes. If this type is not sealed, it can be used as a base class of other types.
(5) What is the default parameter transfer?
Variables are passed by reference (for example, the address of the variable is passed into the called function)
(6) can this type rewrite system. Object. Finalize ()?
It can be overwritten indirectly.
(7) Can I define constructors for this type?
Of course!
(8) When will this type of variable die?
When the managed heap is reclaimed.