Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is the 'Is' VB.NET keyword the same as Object.ReferenceEquals?

Is the Is VB.NET keyword the same as Object.ReferenceEquals?

like image 335
Shimmy Weitzhandler Avatar asked Apr 13 '10 00:04

Shimmy Weitzhandler


1 Answers

Yes, it is, unless combined with a TypeOf check.

Quote from MSDN:

The Is operator determines if two object references refer to the same object. However, it does not perform value comparisons. If object1 and object2 both refer to the exact same object instance, result is True; if they do not, result is False.

Is can also be used with the TypeOf keyword to make a TypeOf...Is expression, which tests whether an object variable is compatible with a data type.

BTW, also note the IsNot operator (which gives the boolean inverse of the matching Is expression):

IsNot is the opposite of the Is operator. The advantage of IsNot is that you can avoid awkward syntax with Not and Is, which can be difficult to read.

like image 171
M.A. Hanin Avatar answered Oct 09 '22 11:10

M.A. Hanin