Message-ID: <1096439272.3301.1419139773694.JavaMail.email@example.com> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_3300_47724629.1419139773693" ------=_Part_3300_47724629.1419139773693 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
Value types in boo are like value types in C# and include int, d= ouble, and other basic types. User-defined value types can be created in bo= o by defining a struct or inheriting from System.V= alueType.=20
Value types are constructed on the stack rather than the heap as objects= are. This makes them faster to create and dispose of, and they don't need = to be garbage collected. User-defined value types can have methods and fiel= ds, just like classes. Value types cannot inherit from other types (excepti= on - all value types inherit from System.ValueType, which itself inherits f= rom object), and other types cannot inherit from value typ= es. Value types can implement interfaces.=20
Here's an example showing the implementation of a Point= value type by inheriting from System.ValueType.=20 =20
When p1 is assigned to p2, the content= s of p1 are physically copied to p2. If <= strong>Point were a class (classes are reference types), the assig= nment would simply copy a pointer to p1 into p2 and the assertion would fail.=20
Here's the equivalent definition for Point implemented using str= uct:=20 =20
Note that by default, fields are public in a struct.