. NET Value Type and reference type,. net reference
C # Is a Type-safe development language. Its data types include Value Type and Reference Type.
1. Value Type)
- Character: char U + 0000-U + ffff 16-bit Unicode character (in fact, the character is also an integer)
- Integer: sbyte, byte, short, ushort, int, uint, long, ulong
- Float: float (7-bit valid values) and double (15-16-bit valid values)
- Decimal: 128-bit data type, which has higher precision (28-29-bit valid bits) and a smaller range than the floating point type, and is suitable for financial and currency computing.
- Boolean: bool (True or False, True or False)
- Structure: struct
- Example: enum
Summary of value types:
* ******************* Struct corresponding to the value type *************** *****
Char Char
Sbyte SByte
Byte Byte
Short Int16
Ushort UInt16
Int Int32
Uint UInt32
Long Int64
Ulong UInt64
Float Single
Double Double
Decimal Decimal
Bool Boolean
**************************************** *************
2. Reference Type (the referenced Type variable is also called an object)
- Class: class
- Interface: interface
- Delegate: delegate
- Object: built-in reference type of. NET
- String:. NET built-in reference type
Reference Type summary:
Class: Abstraction of objects with the same features
Interface: Unified constraints for seamless data sharing and communication between objects of different classes
Delegate: similar to the pointer in C ++, the method name can be passed as a parameter. The difference is that delegate is type-safe.
Object: base class of all classes in. NET
String: string (a sequence consisting of zero or multiple Unicode characters)
Iii. Comparison between value types and reference types