显式数值转换用于通过显式转换表达式,将任何数字类型转换为任何其他数字类型。对于它不存在隐式转换。下表显示了这些转换。

从 到

sbyte

byte、ushort、uint、ulong 或 char

byte

Sbyte 或者 char

short

sbyte、 byte、 ushort、 uint、 ulong 或 char

ushort

sbyte、 byte、 short 或 char

int

sbyte、 byte、 short、 ushort、 uint、 ulong 或 char

uint

sbyte、byte、 short、 ushort、 int 或 char

long

sbyte、 byte、 short、 ushort、 int、 uint、 ulong 或 char

ulong

sbyte、 byte、 short、 ushort、 int、 uint、 long 或 char

char

sbyte、byte 或 short

float

sbyte、 byte、 short、 ushort int、 uint、 long、 ulong、 char 或 decimal

double

sbyte、 byte、 short、 ushort、 int、 uint、 long、 ulong、 char、 float 或 decimal

decimal

sbyte、 byte、 short、 ushort、 int、 uint、 long、 ulong、 char、 float 或 double

Expand 图像备注

Expand image请参见