Table of Contents 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 Notes DownloadECMA-334 C# Language Specification


13 Conversions
13.2 Explicit conversions
13.2.3 Explicit reference conversions
Paragraph 11 The explicit reference conversions are: - 2 From object to any reference-type.
- 3 From any class-type S to any class-type T, provided S is a base class of T.
- 4 From any class-type S to any interface-type T, provided S is not sealed and provided S does not implement T.
- 5 From any interface-type S to any class-type T, provided T is not sealed or provided T implements S.
- 6 From any interface-type S to any interface-type T, provided S is not derived from T.
- 7 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:
- 8 S and T differ only in element type. 9 (In other words, S and T have the same number of dimensions.)
- 10 Both SE and TE are reference-types.
- 11 An explicit reference conversion exists from SE to TE.
- 12 From System.Array and the interfaces it implements, to any array-type.
- 13 From System.Delegate and the interfaces it implements, to any delegate-type.
Paragraph 21 The explicit reference conversions are those conversions between reference-types that require run-time checks to ensure they are correct.
Paragraph 31 For an explicit reference conversion to succeed at run-time, the value of the source operand must be null, or the actual type of the object referenced by the source operand must be a type that can be converted to the destination type by an implicit reference conversion (§13.1.4). 2 If an explicit reference conversion fails, a System.InvalidCastException is thrown.
Paragraph 41 Reference conversions, implicit or explicit, never change the referential identity of the object being converted. [Note: 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. end note] |
Jagger Software Ltd |
Company # 4070126 |
VAT # 762 5213 42 |

