Robin:
In C# the '(type)value' syntax is used for both
casting and type conversion. When applied to an ob-
ject, it works as casting. Since x contains a
short, it cannot be cast as an int. But you can
cast and then convert the type as per:
short i = 10;
object x = i;
int j = ( int )( short )x;
where '( short )' casts and '( int )' converts type.
Terminology can be tricky.
The distinction between cast for references/pointers
and conversion for values is common.
But I think it is OK to call both for cast in C# given
that the C# spec says:
<quote>
7.7.6 Cast expressions
A cast-expression is used to explicitly convert an expression to a given
type.
cast-expression:
( type ) unary-expression
A cast-expression of the form (T)E, where T is a type and E is a
unary-expression, performs an explicit conversion (§6.2) of the value of
E to type T. If no explicit conversion exists from E to T, a
binding-time error occurs. Otherwise, the result is the value produced
by the explicit conversion. The result is always classified as a value,
even if E denotes a variable.
</quote>
<quote>
6.2.1 Explicit numeric conversions
....
Because the explicit conversions include all implicit and explicit
numeric conversions, it is always possible to convert from any
numeric-type to any other numeric-type using a cast expression (§7.7.6).
</quote>
Arne