C#数据类型
string类型赋值要用双引号,例如:string ask = "123";
而char类型赋值要用单引号,并且只能是一个数值,例如:char ask = '1';
| 作用 | 大小 | C# | 大小 | .NET Framework类型 | 取值范围 | |
| 字符 | 1 | sbyte | 1 | System.SByte | -128~127 | |
| 字符(无符号) | 1 | byte | 1 | System.Byte | 0~255 | |
| 宽字符 | wchar_t | 2 | char | 2 | System.Char | |
| 宽字符(无符号) | unsigned wchar_t | 2 | ||||
| 逻辑值 | bool | 1 | bool | 1 | System.Boolean | true,false |
| 短整数 | short | 2 | short | 2 | System.Int16 |
-32,768 .. 32,767 |
| 短整数(无符号) | unsigned short | 2 | ushort | 2 | System.UInt16 | 0~65535(2的16次方) |
| 整数 | int | 4 | int | 4 | System.Int32 |
-2,147,483,648 .. 2,147,483,647 |
| 整数(无符号) | unsigned int | 4 | uint | 4 | System.UInt32 |
0 .. 4,294,967,295 |
| 长整型 | long | 8 | long | 8 | System.Int64 |
-9,223,372,036,854,775,808 .. 9,223,372,036,854,775,807 |
| 长整型(无符号) | unsigned long | 8 | ulong | 8 | System.UInt64 |
0 .. 18,446,744,073,709,551,615 |
| 单精度实数 | float | 4 | float | 4 | System.Single |
-3.402823e38 .. 3.402823e38 |
| 双精度实数 | double | 8 | double | 8 | System.Double |
-1.79769313486232e308 .. 1.79769313486232e308 |
| 长双精度实数 | long double | 10 | decimal | 16 | System.Decimal |
-79228162514264337593543950335 .. 79228162514264337593543950335 |
| 字符串 | string | string | System.String | |||
| 对象 | object | System.Object |

浙公网安备 33010602011771号