C#类型 |
C++/CLI类型 |
.NET框架类型 |
值类型 |
字节/位数 |
范围和精度 |
bool |
bool |
System.Boolean |
真或假 |
-/1 |
true或false |
char |
wchar_t |
System.Char |
字符 |
2/16 |
所有UTF-16编码(0~0xFFFF) |
sbyte |
[signed] char |
System.SByte |
整数 |
1/8 |
-128 ~ 127 |
byte |
unsigned char |
System.Byte |
1/8 |
0 ~ 255 | |
short |
[signed] short |
System.Int16 |
2/16 |
-32 768 ~ 32 767 | |
ushort |
unsigned short |
System.UInt16 |
2/16 |
0 ~ 65 535 | |
int |
[signed] int/long |
System.Int32 |
4/32 |
-2 147 483 648 ~ 2 147 483 647 | |
uint |
unsigned int/long |
System.UInt32 |
4/32 |
0 ~ 4 294 967 295 | |
long |
[signed] long long |
System.Int64 |
8/64 |
-9 223 372 036 854 775 808
~ 9 223 372 036 854 775 807 | |
ulong |
unsigned long long |
System.UInt64 |
8/64 |
0 ~ 18 446 744 073 709 551 615 | |
float |
float |
System.Single |
浮点数 |
4/32 |
±1.5×10-45 ~ ±3.4×1038 |
double |
double |
System.Double |
8/64 |
±5.0×10-324 ~ ±1.7×10308 | |
decimal |
Decimal |
System.Decimal |
高精度十进制小数 |
16/128 |
±1.0×10-28 ~ ±7.9×1028 |
![(C#基本语法)3.简单类型_C#](https://s2.51cto.com/images/editer/InBlock.gif)
![(C#基本语法)3.简单类型_C#](https://s2.51cto.com/images/editer/InBlock.gif)
![(C#基本语法)3.简单类型_C#](https://s2.51cto.com/images/editer/InBlock.gif)
![(C#基本语法)3.简单类型_C#](https://s2.51cto.com/images/editer/InBlock.gif)
![(C#基本语法)3.简单类型_C#](https://s2.51cto.com/images/editer/InBlock.gif)
![(C#基本语法)3.简单类型_C#](https://s2.51cto.com/images/editer/InBlock.gif)
![(C#基本语法)3.简单类型_C#](https://s2.51cto.com/images/editer/InBlock.gif)
![(C#基本语法)3.简单类型_C#](https://s2.51cto.com/images/editer/InBlock.gif)