Information Technology Reference
In-Depth Information
Explicit Numeric Conversions
You've seen that the implicit conversions automatically convert from the source expression to
the target type because there is no possible loss of data. With the explicit conversions, however,
there is the possibility of losing data—so it is important for you as the programmer to know
how a conversion will handle that loss if it occurs.
In this section, you will look at each of the various types of explicit numeric conversions.
Figure 18-10 shows the subset of explicit conversions shown in Figure 18-8.
Figure 18-10. The explicit numeric conversions
Integral to Integral
Figure 18-11 shows the behavior of the integral-to-integral explicit conversions. In the checked
case, if the conversion loses data, the operation raises an OverflowException exception. In the
unchecked case, any lost bits go unreported.
Figure 18-11. Integer type to integer type explicit conversions
Search WWH ::




Custom Search