X hits on this document





111 / 396


From ulong to float, double, or decimal.

From char to ushort, int, uint, long, ulong, float, double, or decimal.

From float to double.

Conversions from int, uint, long, or ulong to float and from long or ulong to double may cause a loss of precision, but will never cause a loss of magnitude. The other implicit numeric conversions never lose any information.

There are no implicit conversions to the char type, so values of the other integral types do not automatically convert to the char type.

6.1.3 Implicit enumeration conversions

An implicit enumeration conversion permits the decimal-integer-literal 0 to be converted to any enum-type.

6.1.4 Implicit reference conversions

The implicit reference conversions are:

From any reference-type to object.

From any class-type S to any class-type T, provided S is derived from T.

From any class-type S to any interface-type T, provided S implements T.

From any interface-type S to any interface-type T, provided S is derived from T.

From an array-type S with an element type SE to an array-type T with an element type TE, provided all of the following are true:

S and T differ only in element type. In other words, S and T have the same number of dimensions.

Both SE and TE are reference-types.

An implicit reference conversion exists from SE to TE.

From any array-type to System.Array.

From any delegate-type to System.Delegate.

From the null type to any reference-type.

The implicit reference conversions are those conversions between reference-types that can be proven to always succeed, and therefore require no checks at run-time.

Reference conversions, implicit or explicit, never change the referential identity of the object being converted. In other words, while a reference conversion may change the type of the reference, it never changes the type or value of the object being referred to.

6.1.5 Boxing conversions

A boxing conversion permits any value-type to be implicitly converted to type object or System.ValueType or to any interface-type implemented by the value-type. Boxing a value of a value-type consists of allocating an object instance and copying the value-type value into that instance. A struct can be boxed to the type System.ValueType, since that is a base class for all structs (§‎11.3.2).

Boxing conversions are described further in §‎4.3.1.

6.1.6 Implicit constant expression conversions

An implicit constant expression conversion permits the following conversions:

A constant-expression (§‎7.15) of type int can be converted to type sbyte, byte, short, ushort, uint, or ulong, provided the value of the constant-expression is within the range of the destination type.

98Copyright Microsoft Corporation 1999-2003. All Rights Reserved.

Document info
Document views1209
Page views1209
Page last viewedThu Jan 19 02:48:45 UTC 2017