Stack features fast and efficient, but its disadvantage is that there are limits and data is not flexible. Stack features flexibility and convenience, wide Data Adaptability, but the efficiency is reduced. Stack memory allocation is automatically released, so there is no release function. Heap space allocation is always dynamic. Although all data space will be released back to the system at the end of the program, precise memory application/release matching is the basic element of a good program.. NET.
Except for the interface, the types in the general type system are divided into two types: Value Type and reference type. There are some performance problems when using the reference type. Therefore, if a system uses all the reference types, the performance of this system will be greatly reduced. the NET Framework designer retains the struct data type, but there is no struct data type in java.
Value Type:
Including primitive type, user-defined structure, or enumeration type
Inherited from System. ValueType type
Allocate on Stack
Assign values by copying
By default, parameters are passed by value unless the ref keyword is used.
Reference Type:
C # pre-defined reference types include object and string. User-defined reference types can be interface type, class type, and delegate type.
Inherited from System. Object Type
Use the "new" keyword for allocation on the managed Stack
Assign values by referencing
Several references may point to the same object. Therefore, operations on one variable may affect the same object referenced by another variable.
Use references to pass variables