Asp tutorial. net c # value type and reference type
C # has two types: value type and reference type ).
Variables of the value type directly contain their data, while variables of the reference type store references to their data. The latter is called an object.
For the reference type, two variables may reference the same object. Therefore, operations on one variable may affect the objects referenced by another variable.
For value types, each variable has its own data copy (except for the ref and out parameter variables). Therefore, operations on one variable cannot affect another variable.
C # values are further divided into simple type, enum type, struct type, and nullable type ).
The reference types of c # are further divided into class type, interface type, array type, and delegate type ).
The following table provides an overview of the c # type system.
Category
Description
Value Type
Simple Type
Signed integer: sbyte, short, int, and long
Unsigned integer: byte, ushort, uint, and ulong
Unicode Character Type: char
Ieee floating point: float and double
Decimal type with High Precision
Boolean: bool
Enumeration type
User-Defined type in the form of enum e {...}
Structure Type
User-Defined type in the form of struct s {...}
It can be a null type.
All other extensions with null values
Reference Type
Class type
Other types of final base class: object
Unicode string: string
User-Defined type in the form of class c {...}
Interface Type
User-Defined type in the form of interface I {...}
Array type
One-dimension and multi-dimensional arrays, such as int [] and int [,]
Delegate type
For example, a user-defined type in the form of delegate int d (...)
The eight integer types support 8-bit, 16-bit, 32-bit, and 64-bit integer values in signed and unsigned forms.
Two floating point types: float and double, which are expressed in the ieee 754 format with 32-bit single precision and 64-bit double precision, respectively.
The decimal type is a 128-bit data type and is suitable for finance and currency computing.
The bool type of c # is used to indicate the Boolean value-true or false.
In c #, character and string processing uses unicode encoding. The char type represents a UTF-16 encoding unit, and the string type represents a sequence of UTF-16 encoding units.