Jon Jagger
jon@jaggersoft.com
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 18 Structsprevious at this levelnext at this level 18.3 Class and struct differencesprevious at this levelnext at this level 18.3.5 Boxing and unboxing Paragraph 11 A value of a class type can be converted to type object or to an interface type that is implemented by the class simply by treating the reference as another type at compile-time. 2 Likewise, a value of type object or a value of an interface type can be converted back to a class type without changing the reference (but of course a run-time type check is required in this case). Paragraph 21 Since structs are not reference types, these operations are implemented differently for struct types. 2 When a value of a struct type is converted to type object or to an interface type that is implemented by the struct, a boxing operation takes place. 3 Likewise, when a value of type object or a value of an interface type is converted back to a struct type, an unboxing operation takes place. 4 A key difference from the same operations on class types is that boxing and unboxing copies the struct value either into or out of the boxed instance. [Note: Thus, following a boxing or unboxing operation, changes made to the unboxed struct are not reflected in the boxed struct. end note] Paragraph 31 For further details on boxing and unboxing, see §11.3.
{ JSL }
Jagger Software Ltd
Company # 4070126
VAT # 762 5213 42
Valid HTML 4.01Valid CSS