System.ValueType Class

public abstract class ValueType

Base Types

Object
  ValueType

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.

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

Value is 3.

See Also

System Namespace

Members

ValueType Constructors

ValueType Constructor

ValueType Methods

ValueType.Equals Method
ValueType.GetHashCode Method
ValueType.ToString Method


ValueType Constructor

protected ValueType();

Summary

Constructs a new instance of the ValueType class.

See Also

System.ValueType Class, System Namespace

ValueType.Equals Method

public override bool Equals(object obj);

Summary

Determines whether the current instance and a specified Object represent the same value.

Parameters

obj
The Object to compare the current instance to.

Return Value

true if obj and the current instance are of the same type and represent the same value; otherwise, false .

Description

[Note: This method overrides System.Object.Equals(System.Object) .]

See Also

System.ValueType Class, System Namespace

ValueType.GetHashCode Method

public override int GetHashCode();

Summary

Generates a hash code for the current instance.

Return Value

A Int32 containing the hash code for the current instance.

Description

The algorithm used to generate the hash code is unspecified.

[Note: This method overrides System.Object.GetHashCode .]

See Also

System.ValueType Class, System Namespace

ValueType.ToString Method

public override string ToString();

Summary

Returns a String representation of the fully-qualified name of the type of the current instance.

Return Value

A String representation of the fully-qualified name of the type of the current instance.

Description

[Note: This method overrides System.Object.ToString.

This method returns the System.Type.FullName property.

]

See Also

System.ValueType Class, System Namespace