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 Structs Paragraph 11 Structs are similar to classes in that they represent data structures that can contain data members and function members. 2 However, unlike classes, structs are value types and do not require heap allocation. 3 A variable of a struct type directly contains the data of the struct, whereas a variable of a class type contains a reference to the data, the latter known as an object. [Note: Structs are particularly useful for small data structures that have value semantics. Complex numbers, points in a coordinate system, or key-value pairs in a dictionary are all good examples of structs. Key to these data structures is that they have few data members, that they do not require use of inheritance or referential identity, and that they can be conveniently implemented using value semantics where assignment copies the value instead of the reference. end note] Paragraph 21 As described in §11.1.3, the simple types provided by C#, such as int, double, and bool, are, in fact, all struct types. 2 Just as these predefined types are structs, it is also possible to use structs and operator overloading to implement new "primitive" types in the C# language. 3 Two examples of such types are given at the end of this chapter (§18.4).
{ JSL }
Jagger Software Ltd
Company # 4070126
VAT # 762 5213 42
Valid HTML 4.01Valid CSS