Widening conversions always succeed and never cause information to be lost. The following conversions are classified as widening conversions:
Byte
, Short
, Integer
, Long
, Decimal
, Single
, Double
. Conversions from Integer
to Single
, Long
to Single
or Double
or Decimal
to Single
or Double
may cause a loss of precision, but will never cause a loss of magnitude. The other widening numeric conversions never lose any information.Nothing
to any numeric type. Nothing
converts to the literal 0
. This is useful for math operations involving Object
.Nothing
to any reference type.0
to any enumerated typeS
with an element type SE
to a covariant array type T
with an element type TE
, provided all of the following are true:
S
and T
differ only in element typeSE
and TE
are reference typesSE
to TE
Char
to String
Long
, Integer
, Short
or Byte
to a narrower type, provided the value of the constant expression is within the range of the destination type.