float
or
double
to
decimal
, and it is not possible to mix
ulong
with any signed integer type.
To mix these types requires the use of an explicit cast.
Second, pay special attention to the last rule. It states that if none of the preceding rules
applies, then all other operands are promoted to
int
. Therefore, in an expression, all
char
,
sbyte
,
byte
,
ushort
, and
short
values are promoted to
int
for the purposes of calculation.
This is called
integer promotion.
It also means that the outcome of all arithmetic operations
will be no smaller than
int
.
It is important to understand that type promotions only apply to the values operated
upon when an expression is evaluated. For example, if the value of a
Do'stlaringiz bilan baham: |