不是或<>? [英] not or <>?

查看:47
本文介绍了不是或<>?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

哪个更快?


如果strMessage<> String.Empty然后


结束如果





如果不是strMessage则什么都没有


结束如果

解决方案

Kerberoz,


比较string.empty较慢,因为这会调用对StrCmp的调用来比较两个字符串并返回结果。看看以下

IL for if strMessage<> String.Empty


IL_0008:调用int32

[Microsoft.VisualBasic] Microsoft.VisualBasic.CompilerServices.StringType :: St

rCmp(字符串,



bool)


干杯,

Lubos

" kerberoz" <德**** @ hotmail.com>在消息中写道

新闻:eX ************** @ TK2MSFTNGP11.phx.gbl ...

哪个更快?

如果strMessage<> String.Empty然后

结束如果



如果不是strMessage什么都没有那么

结束如果



我会指出这两个相等的测试做的很不一样。

的东西。

如果strMessage<> String.Empty然后''这测试一个零长度字符串


如果If Not strMessage Is Nothing那么''这测试是否参考是

与此标识符相关联。


苹果和梨子!

问候 - OHM


kerberoz写道:

哪个更快?

如果strMessage<> String.Empty那么

结束如果



如果不是strMessage什么都没有那么

结束如果



-

最诚挚的问候 - OHM


O_H_M {at} BTInternet {dot} com


你好Kerberoz


除了OHT


在这个新闻组我们大多建议使用

strMessage<> "

或很少

strMessage<>什么都没有

但从来没有

strMessage<> String.Empty


Cor

哪个更快?

如果strMessage<> String.Empty然后

结束如果



如果不是strMessage什么都没有那么

结束如果



which is faster?

If strMessage <> String.Empty Then

End If

or

If Not strMessage Is Nothing Then

End If

解决方案

Kerberoz,

Comparing against string.empty is slower as this invokes a call to StrCmp to
compare the two strings and return the result. Take a look at the following
IL for If strMessage <> String.Empty

IL_0008: call int32
[Microsoft.VisualBasic]Microsoft.VisualBasic.CompilerServices.StringType: :St
rCmp(string,

string,

bool)

Cheers,
Lubos
"kerberoz" <de****@hotmail.com> wrote in message
news:eX**************@TK2MSFTNGP11.phx.gbl...

which is faster?

If strMessage <> String.Empty Then

End If

or

If Not strMessage Is Nothing Then

End If



I would point out that these two equality test are doing very different
things.

If strMessage <> String.Empty Then '' This tests for a zero length string

if If Not strMessage Is Nothing Then '' This tests to see if a reference is
associated with this identifier.

Apples and Pears !
Regards - OHM

kerberoz wrote:

which is faster?

If strMessage <> String.Empty Then

End If

or

If Not strMessage Is Nothing Then

End If



--
Best Regards - OHM

O_H_M{at}BTInternet{dot}com


Hi Kerberoz

In addition to OHT

In this newsgroup we mostly advice to use
strMessage <> ""
or seldom
strMessage <> nothing
but never
strMessage <> String.Empty

Cor

which is faster?

If strMessage <> String.Empty Then

End If

or

If Not strMessage Is Nothing Then

End If



这篇关于不是或&lt;&gt;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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