VB.NET关键字是否与Object.ReferenceEquals相同? [英] Is the 'Is' VB.NET keyword the same as Object.ReferenceEquals?

查看:95
本文介绍了VB.NET关键字是否与Object.ReferenceEquals相同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

推荐答案

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

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

来自MSDN的报价:

Is运算符确定两个 对象引用指的是相同的 目的.但是,它不执行 价值比较.如果object1和 object2都指的是完全相同的 对象实例,结果为True;如果 他们没有,结果是False.

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.

也可以与TypeOf一起使用 创建TypeOf ...是的关键字 表达式,用于测试是否 对象变量与 数据类型.

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表达式的布尔逆):

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

IsNot与Is相反 操作员. IsNot的优点是 您可以避免使用笨拙的语法 不和是,这可能很难 阅读.

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关键字是否与Object.ReferenceEquals相同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆