This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!
Value Type Definition
Not all types defined by a class definition are object types (see Classes, Interfaces and Objects); in particular, value types are not object types but they are defined using a class definition. A class definition for a value type defines both the (unboxed) value type and the associated boxed type (see Boxing and Unboxing of Values). The members of the class definition define the representation of both:
- When a non-static method (i.e. an instance or virtual method) is called on the value type its this pointer is a managed reference to the instance, whereas when the method is called on the associated boxed type the this pointer is an object reference.
Note: In PDC boxed value types don’t exist as independent types. Therefore, instance methods on value types receive a this pointer that is a managed pointer to the unboxed type whereas virtual methods (including those on interfaces implemented by the value type) receive an instance of the boxed type.
- Value types do not support interface contracts, but their associated boxed types do.
- A value type does not inherit; rather the base type specified in the class definition defines the base type of the boxed type.
- The base type of a boxed type cannot have any fields.
- Unlike object types, instances of value types do not require a constructor to be called when an instance is created. Instead, the contents of a value type are guaranteed to be initially zero (null for object fields).