System.ValueType Class

Base Types

Assembly

mscorlib

Library

BCL

Summary

Provides support for value types. This class is the base class for all value types.

Description

[Note: Data types are separated into value types and reference
types. Value types are either stack-allocated or allocated inline in a
structure. Reference types are heap-allocated. Both reference and value types
are derived from the ultimate base class Object. In cases where a value type needs to
act like an object, a wrapper that makes the value type look like a reference
object is allocated on the heap, and the value type's value is copied into it.
The wrapper is marked so that the system knows that it contains a value type.
This process is known as boxing, and the reverse process is known as unboxing.
Boxing and unboxing allow any type to be treated as an object.

]

Example

In the following example, the number 3 is boxed as a Int32, and System.Int32.ToString () is
called.