IsNothing vs. Is Nothing [英] IsNothing vs. Is Nothing

查看:92
本文介绍了IsNothing vs. Is Nothing的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 - 只是一个简单的问题。


我想知道哪个更好VB.Net方式 - 使用IsNothing或

在If..Then声明中没有任何内容


例如:


如果IsNothing(myObject)那么

''等等等等......

结束如果


vs


如果myObject什么都没有那么

''等等等等等等等...
结束如果


谢谢

史蒂夫

Hi - just a quick question.

I was wondering which is the better "VB.Net" way - to use IsNothing or the
Is Nothing in an If..Then statement

For example:

If IsNothing(myObject) then
''blah blah blah..
End If

vs

If myObject Is Nothing then
''blah blah blah..
End If

Thanks
Steve

推荐答案

*" Steve Peterson" < FA ****** @ fakemail.com> scripsit:
* "Steve Peterson" <fa******@fakemail.com> scripsit:
我想知道哪个更好VB.Net方式 - 使用IsNothing或
在If..Then声明中没有任何内容

例如:

如果IsNothing(myObject)那么
' '等等等等......
结束如果


如果myObject什么都没有那么
''等等等等等等等。
结束如果
I was wondering which is the better "VB.Net" way - to use IsNothing or the
Is Nothing in an If..Then statement

For example:

If IsNothing(myObject) then
''blah blah blah..
End If

vs

If myObject Is Nothing then
''blah blah blah..
End If




您是否使用

" ildasm.exe>来查看已编译可执行文件的MSIL代码?


;-)

-

Herfried K. Wagner

MVP·VB Classic, VB.NET

< http://www.mvps.org/dotnet>


< http://www.plig.net/nnq /nquote.html>



Did you have a look at the MSIL code of the compiled executable using
"ildasm.exe"?

;-)

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

<http://www.plig.net/nnq/nquote.html>


史蒂夫,

我不相信其中任何一个都是更好的然后是另一个。


我更喜欢myObject Is Nothing,但这并不能使它更好。


我会更关心在项目中保持一致,

解决方案,团队,公司。


希望这有帮助

Jay


" Steve Peterson" < FA ****** @ fakemail.com>在消息中写道

news:u%**************** @ TK2MSFTNGP12.phx.gbl ...
Steve,
I don''t believe either is really "better" then the other.

I prefer myObject Is Nothing, however that does not make it "Better".

I would be more concerned with being consistent within the project,
solution, team, company.

Hope this helps
Jay

"Steve Peterson" <fa******@fakemail.com> wrote in message
news:u%****************@TK2MSFTNGP12.phx.gbl...
嗨 - 我只是想知道哪个更好VB.Net。方式 - 使用IsNothing或
在If..Then声明中没有任何内容

例如:

如果IsNothing(myObject)那么
' '等等等等......
结束如果


如果myObject什么都没有那么
''等等等等等等等。
结束如果

谢谢
史蒂夫
Hi - just a quick question.

I was wondering which is the better "VB.Net" way - to use IsNothing or the
Is Nothing in an If..Then statement

For example:

If IsNothing(myObject) then
''blah blah blah..
End If

vs

If myObject Is Nothing then
''blah blah blah..
End If

Thanks
Steve



Hi Herfield


嗯,我想如果我有,或者甚至不知道你在说什么,我

可能不会在第一时间发布我的问题..


如果你想要解释一下你的答案,那么也许我(以及

其他人)对我们未来的道路将会有一些宝贵的见解。 />
更好.Net程序员...


谢谢

史蒂夫


" Herfried K. Wagner [MVP]" <喜*************** @ gmx.at>在消息中写道

news:bp ************* @ ID-208219.news.uni-berlin.de ...
Hi Herfield

Mmm, I guess if I had, or even had a clue what you are talking about, I
probably wouldn''t have posted my question in the first place..

If you would be so kind as to decipher your answer a bit, maybe I (and
others) would have some valuable insight for the future on our road to being
better .Net programmers...

Thanks
Steve

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:bp*************@ID-208219.news.uni-berlin.de...
您是否使用
ildasm.exe查看已编译可执行文件的MSIL代码?

;-)

-
Herfried K. Wagner
MVP·VB Classic,VB.NET
< http://www.mvps.org/dotnet>

< http: //www.plig.net/nnq/nquote.html>
Did you have a look at the MSIL code of the compiled executable using
"ildasm.exe"?

;-)

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

<http://www.plig.net/nnq/nquote.html>



这篇关于IsNothing vs. Is Nothing的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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