X hits on this document

1139 views

0 shares

0 downloads

0 comments

112 / 396

Chapter ‎18   Unsafe code

A constant-expression of type long can be converted to type ulong, provided the value of the constant-expression is not negative.

6.1.7 User-defined implicit conversions

A user-defined implicit conversion consists of an optional standard implicit conversion, followed by execution of a user-defined implicit conversion operator, followed by another optional standard implicit conversion. The exact rules for evaluating user-defined conversions are described in §‎6.4.3.

6.2 Explicit conversions

The following conversions are classified as explicit conversions:

All implicit conversions.

Explicit numeric conversions.

Explicit enumeration conversions.

Explicit reference conversions.

Explicit interface conversions.

Unboxing conversions.

User-defined explicit conversions.

Explicit conversions can occur in cast expressions (§‎7.6.6).

The set of explicit conversions includes all implicit conversions. This means that redundant cast expressions are allowed.

The explicit conversions that are not implicit conversions are conversions that cannot be proven to always succeed, conversions that are known to possibly lose information, and conversions across domains of types sufficiently different to merit explicit notation.

6.2.1 Explicit numeric conversions

The explicit numeric conversions are the conversions from a numeric-type to another numeric-type for which an implicit numeric conversion (§‎6.1.2) does not already exist:

From sbyte to byte, ushort, uint, ulong, or char.

From byte to sbyte and char.

From short to sbyte, byte, ushort, uint, ulong, or char.

From ushort to sbyte, byte, short, or char.

From int to sbyte, byte, short, ushort, uint, ulong, or char.

From uint to sbyte, byte, short, ushort, int, or char.

From long to sbyte, byte, short, ushort, int, uint, ulong, or char.

From ulong to sbyte, byte, short, ushort, int, uint, long, or char.

From char to sbyte, byte, or short.

From float to sbyte, byte, short, ushort, int, uint, long, ulong, char, or decimal.

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

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

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

Document info
Document views1139
Page views1139
Page last viewedTue Jan 17 17:20:09 UTC 2017
Pages396
Paragraphs9401
Words133190

Comments