13.07.2015 Views

C# Language Specification - Willy .Net

C# Language Specification - Willy .Net

C# Language Specification - Willy .Net

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>C#</strong> LANGUAGE SPECIFICATION• 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 aloss of precision, but will never cause a loss of magnitude. The other implicit numeric conversions neverlose any information.There are no implicit conversions to the char type, so values of the other integral types do not automaticallyconvert to the char type.13.1.3 Implicit enumeration conversionsAn implicit enumeration conversion permits the decimal-integer-literal 0 to be converted to any enum-type.13.1.4 Implicit reference conversionsThe 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 S E to an array-type T with an element type T E , provided allof 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 S E and T E are reference-types.An implicit reference conversion exists from S E to T E .• From any array-type to System.Array.• From any delegate-type to System.Delegate.• From any array-type or delegate-type to System.ICloneable.• From the null type to any reference-type.The implicit reference conversions are those conversions between reference-types that can be proven toalways succeed, and therefore require no checks at run-time.Reference conversions, implicit or explicit, never change the referential identity of the object beingconverted. [Note: In other words, while a reference conversion may change the type of the reference, it neverchanges the type or value of the object being referred to. end note]13.1.5 Boxing conversionsA boxing conversion permits any value-type to be implicitly converted to the type object orSystem.ValueType or to any interface-type implemented by the value-type. Boxing a value of a valuetypeconsists of allocating an object instance and copying the value-type value into that instance. A structcan be boxed to the type System.ValueType, since that is a base class for all structs (§18.3.2).Boxing conversions are described further in §11.3.1.13.1.6 Implicit constant expression conversionsAn implicit constant expression conversion permits the following conversions:114

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!