Collection
zero Useful+1
zero

Value Type

Terminology in computer field
The concept of value type often appears in books of programming languages such as C # and Java The "value type" directly stores the memory in the stack system The data type that automatically releases resources
The reference type corresponding to the value type C # language also corresponds to Pointer Type
Chinese name
Value Type
Discipline
computer

Programming type

Announce
edit
Every programming language has some very small differences in value types NET framework C # programming language value type definition
Generally speaking, the value types of C # are: [1]
Integer: Int;
Long: long;
Floating point: float;
Character type: char;
Boolean: bool;
Enumeration: enum;
Structure: struct;
All value types in C # inherit from: System ValueType

major function

Announce
edit
Variables based on value types contain values directly. [2] When a value type variable is assigned to another value type variable, the included value will be copied. This is different from the assignment of reference type variables. The assignment of reference type variables only copies the reference to the object, not the object itself.
All value types are implicitly derived from SystemValueType.
And reference type Different, you cannot derive a new type from a value type. But like reference types, structures can also implement interfaces.
Unlike reference types, value types cannot contain null values. However, the type feature that can be null allows value types to be assigned to null.
Each value type has an implicit Default constructor To initialize the default value of the type.

Median Type

Announce
edit
Before using local variables in C #, they must be initialized. For example, uninitialized local variables may be declared, as shown in the following example: [3]
int myInt;
This variable cannot be used until it is initialized. You can initialize it with the following statement:
myInt = new int();
This statement is the equivalent of the following statements:
myInt = 0;
Of course, you can use the same statement for declaration and initialization, as shown in the following example:
int myInt = new int();
-Or-
int myInt = 0;
When the new operator is used, the default constructor of a specific type is called and the variable is assigned a default value. In the above example, the default constructor assigns the value 0 to myInt.
For user-defined types, use new to call the default constructor. For example, the following statement calls the default constructor of the Point structure:
Point p = new Point();
After this call, the structure is considered to have been explicitly assigned; That is, all members of the structure have been initialized to their default values.