C#中的除法运算符与VB.NET中的除法运算符

2020-01-06 13:05:22王冬梅

 

执行除法之前,任何整数数值表达式都会被扩展为 Double。 如果将结果赋给整数数据类型,Visual Basic 会尝试将结果从 Double 转换成这种类型。 如果结果不适合该类型,会引发异常。如果除数或被除数计算结果等于 Nothing,则将其视为零。   (整数除法):将两个数相除并返回以整数形式表示的结果。 下表如何确定结果的数据类型。 请注意,此表是对称的;对于给定的操作数数据类型组合,无论操作数的顺序如何,结果数据类型都是相同的。

 

  Boolean SByte Byte Short UShort Integer UInteger Long ULong
Boolean Boolean SByte Short Short Integer Integer Long Long Long
SByte SByte SByte Short Short Integer Integer Long Long Long
Byte Short Short Byte Short UShort Integer UInteger Long ULong
Short Short Short Short Short Integer Integer Long Long Long
UShort Integer Integer UShort Integer UShort Integer UInteger Long ULong
Integer Integer Integer Integer Integer Integer Integer Long Long Long
UInteger Long Long UInteger Long UInteger Long UInteger Long ULong
Long Long Long Long Long Long Long Long Long Long
ULong Long Long ULong Long ULong Long ULong Long ULong