“不是……没什么"与“......不是什么" [英] "Not ... Is Nothing" versus "... IsNot Nothing"

查看:29
本文介绍了“不是……没什么"与“......不是什么"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里有没有人使用 VB.NET 并且强烈偏好或反对使用 Not foo Is Nothing 而不是 foo IsNot Nothing?如果是,为什么?

Does anyone here use VB.NET and have a strong preference for or against using Not foo Is Nothing as opposed to foo IsNot Nothing? If so, why?

例如

If var1 IsNot Nothing Then
...
End If

If Not var1 Is Nothing Then
...
End If

我只想知道哪个更好?
他们都同样可以接受吗?

I just want to know which one is better?
Are they both equally acceptable?

推荐答案

If Not var1 Is Nothing Then

是 VB6 的宿醉.过去没有 IsNot,因此这是确定变量是否不是 Nothing 的唯一方法.在VB.NET中似乎是多余的.

Is a hangover from VB6. There didn't used to be an IsNot, and so this was the only way to determine if a variable was not Nothing. It seems to be redundant in VB.NET.

这篇关于“不是……没什么"与“......不是什么"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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