Information.IsReference(Object) Metoda

Definice

Vrací Boolean hodnotu určující, zda je výraz vyhodnocen jako typ odkazu.Returns a Boolean value indicating whether an expression evaluates to a reference type.

public:
 static bool IsReference(System::Object ^ Expression);
public static bool IsReference (object? Expression);
public static bool IsReference (object Expression);
static member IsReference : obj -> bool
Public Function IsReference (Expression As Object) As Boolean

Parametry

Expression
Object

Povinná hodnota.Required. Object vyjádření.Object expression.

Návraty

Boolean

Vrací Boolean hodnotu určující, zda je výraz vyhodnocen jako typ odkazu.Returns a Boolean value indicating whether an expression evaluates to a reference type.

Příklady

Tento příklad používá IsReference funkci ke kontrole, zda více proměnných odkazuje na odkazové typy.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)

V předchozím příkladu první tři volání IsReference vrátí True .In the preceding example, the first three calls to IsReference return True. Poslední volání vrátí False , protože Integer je typ hodnoty, nikoli odkazový typ.The last call returns False, because Integer is a value type, not a reference type.

Poznámky

IsReference Vrátí, True Pokud Expression představuje typ odkazu, jako je například instance třídy, String typ nebo pole libovolného typu. v opačném případě vrátí False .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.

Odkazový typ obsahuje ukazatel na data uložená jinde v paměti.A reference type contains a pointer to data stored elsewhere in memory. Hodnotový typ obsahuje vlastní data.A value type contains its own data.

Platí pro

Viz také