显式数值转换表

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

 

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

本在线速查手册由www.w♥3♥x♥u♥e.com提供,请勿盗用!

备注

有关显式转换的更多信息,请参见“6.2 C# 语言规范中的显式”。有关如何访问此规范的更多信息,请参见 C# 语言规范