Operator

Is


Description

Compares two object references to determine whether they both refer to the same object.

Usage

result = object1 Is object2

Part

Type

Description

result

Boolean

Any container expecting a boolean value.

object1

Object

Any object name.

object2

Object

Another object name.

Notes

The Is operator returns True if object1 and object2 actually refer to the same object. It checks identity, not contents, so it Is not affected by the presence of a comparison operator. Use it the same way as the = operator.

Sample code

In the following example, the Is operator returns True.

Var d1 As New Dictionary
Var d2 As Dictionary

d2 = d1

If d1 Is d2 Then
  ' d1 and d2 are the same reference
Else
 ' d1 and d2 are not the same reference
End If

Compatibility

All project types on all supported operating systems.

See also

IsA operator.