Value Types and Reference Types
Collapse the table of content
Expand the table of content
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

Value Types and Reference Types

A data type is a value type if it holds the data within its own memory allocation. A reference type contains a pointer to another memory location that holds the data.

Value types include:

  • All numeric data types
  • Boolean, Char, and Date
  • All structures, even if their members are reference types
  • 1Enumerations, since their underlying type is always Byte, Short, Integer, or Long

Reference types include:

  • String
  • All arrays, even if their elements are value types
  • Class types, such as Form
  • Delegates

You can assign either a reference type or a value type to a variable of the Object data type. An Object variable always holds a pointer to the data, never the data itself. However, if you assign a value type to an Object variable, it behaves as if it holds its own data.

You can find out whether an Object variable is acting as a reference type or a value type by passing it to the IsReference method on the Information class in the Microsoft.VisualBasic namespace. Microsoft.VisualBasic.Information.IsReference returns True if the content of the Object variable represents a reference type.

See Also

Data Types as Classes and Structures | Type Conversions | Structures: Your Own Data Types | Efficient Use of Data Types

© 2016 Microsoft