Export (0) Print
Expand All

Information.IsReference Method

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

Namespace:  Microsoft.VisualBasic
Assembly:  Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)

public static bool IsReference(
	Object Expression
)

Parameters

Expression
Type: System.Object

Required. Object expression.

Return Value

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

For more detailed information, see the Visual Basic topic IsReference Function.

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.

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.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 3.5, 2.0, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft