Implicit conversions involving type parameters
The following implicit conversions exist for a given type parameter T: · From T to its effective base class C, from T to any base class of C, and from T to any interface implemented by C. At run-time, if T is a value type, the conversion is executed as a boxing conversion. Otherwise, the conversion is executed as an implicit reference conversion or identity conversion. · From T to an interface type I in T’s effective interface set and from T to any base interface of I. At run-time, if T is a value type, the conversion is executed as a boxing conversion. Otherwise, the conversion is executed as an implicit reference conversion or identity conversion. · From T to a type parameter U, provided T depends on U (§10.1.5). At run-time, if U is a value type, then T and U are necessarily the same type and no conversion is performed. Otherwise, if T is a value type, the conversion is executed as a boxing conversion. Otherwise, the conversion is executed as an implicit reference conversion or identity conversion. · From the null literal to T, provided T is known to be a reference type. · From T to a reference type I if it has an implicit conversion to a reference type S0 and S0 has an identity conversion to S. At run-time the conversion is executed the same way as the conversion to S0. · From T to an interface type I if it has an implicit conversion to an interface or delegate type I0 and I0 is variance-convertible to I (§13.1.3.2). At run-time, if T is a value type, the conversion is executed as a boxing conversion. Otherwise, the conversion is executed as an implicit reference conversion or identity conversion. If T is known to be a reference type (§10.1.5), the conversions above are all classified as implicit reference conversions (§6.1.6). If T is not known to be a reference type, the conversions above are classified as boxing conversions (§6.1.7).
|