vb.net - 'Is' VB.NET关键字是否与Object.ReferenceEquals相同?

标签 vb.net operator-keyword referenceequals

Is VB.NET关键字是否与Object.ReferenceEquals相同?

最佳答案

是的,是的,除非与TypeOf检查结合使用。

从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.



顺便说一句,还要注意IsNot运算符(它给出匹配的Is表达式的 bool 逆):

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.

关于vb.net - 'Is' VB.NET关键字是否与Object.ReferenceEquals相同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2626206/

相关文章:

c++ - 运算符重载插入

c# - 是否可以创建一个引用不等于任何其他字符串的字符串?

java - 在 `equals(T value)` 中,T 必须是 Object,还是可以像 City 等?

c# - 当类型不同但兼容比较值时,如何检查值类型装箱对象的相等性

python - 设置 "in"运算符 : uses equality or identity?

mysql - 为什么我总是收到这个 mysql 错误?

.net - 低优先级运行或设置流程

vb.net - 使用正则表达式从字符串开头删除数字

vb.net - 如何获取屏幕总像素大小

c++ - 三元运算符的奇怪隐式转换