| C# Type | .NET Framework type |
|---|---|
| bool | System.Boolean |
| byte | System.Byte |
| sbyte | System.SByte |
| char | System.Char |
| decimal | System.Decimal |
| double | System.Double |
| float | System.Single |
| int | System.Int32 |
| uint | System.UInt32 |
| long | System.Int64 |
| ulong | System.UInt64 |
| object | System.Object |
| short | System.Int16 |
| ushort | System.UInt16 |
| string | System.String |
Range and Size
| Type | Range | Size |
|---|---|---|
| bool | true or false (1 or 0) | 1 bit |
| sbyte | -128 to 127 | Signed 8-bit integer |
| byte | 0 to 255 | Unsigned 8-bit integer |
| char | U+0000 to U+ffff | Unicode 16-bit character |
| short | -32,768 to 32,767 | Signed 16-bit integer |
| ushort | 0 to 65,535 | Unsigned 16-bit integer |
| int | -2,147,483,648 to 2,147,483,647 | Signed 32-bit integer |
| uint | 0 to 4,294,967,295 | Unsigned 32-bit integer |
| long | -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 | Signed 64-bit integer |
| ulong | 0 to 18,446,744,073,709,551,615 | Unsigned 64-bit integer |
| Type | Approximate range | Precision |
| float | ±1.5 × 10−45 to ±3.4 × 1038 | 7 digits |
| double | ±5.0 × 10−324 to ±1.7 × 10308 | 15-16 digits |
Default values
| Value type | Default value |
|---|---|
| bool | false |
| byte | 0 |
| char | '\0' |
| decimal | 0.0M |
| double | 0.0D |
| enum | The value produced by the expression (E)0, where E is the enum identifier. |
| float | 0.0F |
| int | 0 |
| long | 0L |
| sbyte | 0 |
| short | 0 |
| struct | The value produced by setting all value-type fields to their default values and all reference-type fields to null. |
| uint | 0 |
| ulong | 0 |
| ushort | 0 |
Implicit Numeric Conversions Table
| From | To |
|---|---|
| sbyte | short, int, long, float, double, or decimal |
| byte | short, ushort, int, uint, long, ulong, float, double, or decimal |
| short | int, long, float, double, or decimal |
| ushort | int, uint, long, ulong, float, double, or decimal |
| int | long, float, double, or decimal |
| uint | long, ulong, float, double, or decimal |
| long | float, double, or decimal |
| char | ushort, int, uint, long, ulong, float, double, or decimal |
| float | double |
| ulong | float, double, or decimal |
Explicit Numeric Conversions Table
| From | To |
|---|---|
| sbyte | byte, ushort, uint, ulong, or char |
| byte | sbyte or char |
| short | sbyte, byte, ushort, uint, ulong, or char |
| ushort | sbyte, byte, short, or char |
| int | sbyte, byte, short, ushort, uint, ulong, or char |
| uint | sbyte, byte, short, ushort, int, or char |
| long | sbyte, byte, short, ushort, int, uint, ulong, or char |
| ulong | sbyte, byte, short, ushort, int, uint, long, or char |
| char | sbyte, byte, or short |
| float | sbyte, byte, short, ushort, int, uint, long, ulong, char, or decimal |
| double | sbyte, byte, short, ushort, int, uint, long, ulong, char, float, or decimal |
| decimal | sbyte, byte, short, ushort, int, uint, long, ulong, char, float, or double |
This comment has been removed by a blog administrator.
ReplyDelete