Mono Class Library: System Namespace

System.ValueType Class

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

See Also: ValueType Members

[System.Runtime.InteropServices.ComVisible(true)]
public abstract class ValueType

Thread Safety

All public static members of this type are safe for multithreaded operations. No instance members are guaranteed to be thread safe.

Remarks

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.

[Edit]

Example

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

C# Example
using System;
class Boxer {
  public static void Main() {
   Console.WriteLine("Value is {0}.", 3.ToString());
  }
}

The output is

Value is 3.

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0