Jon Jagger
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 Specificationpreviousnextprevious at this levelnext at this level 11 Typesprevious at this levelnext at this level 11.3 Boxing and unboxingprevious at this levelnext at this level 11.3.2 Unboxing conversions Paragraph 11 An unboxing conversion permits an explicit conversion from type object to any value-type or from any interface-type to any value-type that implements the interface-type. 2 An unboxing operation consists of first checking that the object instance is a boxed value of the given value-type, and then copying the value out of the instance. Paragraph 21 Referring to the imaginary boxing class described in the previous section, an unboxing conversion of an object box to a value-type T consists of executing the expression ((T_Box)box).value. [Example: Thus, the statements
object box = 123;  
int i = (int)box;  
conceptually correspond to
object box = new int_Box(123);  
int i = ((int_Box)box).value;  
end example]
Paragraph 31 For an unboxing conversion to a given value-type to succeed at run-time, the value of the source operand must be a reference to an object that was previously created by boxing a value of that value-type. 2 If the source operand is null or a reference to an incompatible object, a System.InvalidCastException is thrown.
{ JSL }
Jagger Software Ltd
Company # 4070126
VAT # 762 5213 42
Valid HTML 4.01Valid CSS