if I have this expression
long = int * uint * ushort * short;
how is the implicit conversion done here for the different types in this
expression.
It gets evaluated as:
long = (((long)int * (long)uint) * (long)ushort) * (long)short;
1) you can look it up in the C# spec
section "14.2.6.2 Binary numeric promotions" says
• Otherwise, if either operand is of type long, the other operand is
converted to type long.
• Otherwise, if either operand is of type uint and the other operand is
of type sbyte, short, or int,
both operands are converted to type long.
2) you can test it
int v1 = 1;
uint v2 = 2;
Console.WriteLine((v1*v2).GetType().Name);
3) and what you *should* do is avoid it !
You should write code so that any programmer even without
C# knowledge can understand the calculation.
Try and use the same data types.
And if you need to convert then do it explicit. And be
generous with the use of parenthesis's.
Arne