Share via


IsReference Function 

Returns a Boolean value indicating whether an expression evaluates to a reference type.

Public Function IsReference(ByVal Expression As Object) As Boolean

Parameters

  • Expression
    Required. Object expression.

Remarks

IsReference returns True if Expression represents a reference type, such as a class instance, a String type, or an array of any type; otherwise, it returns False.

A reference type contains a pointer to data stored elsewhere in memory. A value type contains its own data.

Example

This example uses the IsReference function to check if several variables refer to reference types.

Dim testArray(3) As Boolean
Dim testString As String = "Test string"
Dim testObject As Object = New Object()
Dim testNumber As Integer = 12
testArray(0) = IsReference(testArray)
testArray(1) = IsReference(testString)
testArray(2) = IsReference(testObject)
testArray(3) = IsReference(testNumber)

In the preceding example, the first three calls to IsReference return True. The last call returns False, because Integer is a value type, not a reference type.

Requirements

Namespace: Microsoft.VisualBasic

Module: Information

Assembly: Visual Basic Runtime Library (in Microsoft.VisualBasic.dll)

See Also

Reference

IsArray Function (Visual Basic)
IsDate Function (Visual Basic)
IsDBNull Function
IsError Function
IsNothing Function
IsNumeric Function (Visual Basic)
Object Data Type
TypeName Function (Visual Basic)

Concepts

Value Types and Reference Types