Message-ID: <1101623591.301413.1369128329068.JavaMail.firstname.lastname@example.org> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_301412_1447480001.1369128329067" ------=_Part_301412_1447480001.1369128329067 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 b= oo by defining a struct or inheriting from System.= ValueType.
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 fi= elds, just like classes. Value types cannot inherit from other types (exce= ption - all value types inherit from System.ValueType, which itself inherit= s from object), and other types cannot inherit from value = types. Value types can implement interfaces.
Here's an example showing the implementation of a Point= value type by inheriting from System.ValueType.
When p1 is assigned to p2, the content= s of p1 are physically copied to p2. If = Point were a class (classes are reference types), the assi= gnment would simply copy a pointer to p1 into p2= strong> and the assertion would fail.
Here's the equivalent definition for Point implemented using str= uct:
Note that by default, fields are public in a struct.------=_Part_301412_1447480001.1369128329067--