检查空白字符串的更好方法 [英] better way of checking for blank string
问题描述
检查空白字符串的更好方法是什么?
strvar.lenght> 0
或
strvar ==""
或其他东西
Thnaks
Vicky< vi *** @hh.com>写道:什么是检查空白字符串的更好方法是
strvar.lenght> 0
strvar ==""
或者别的什么
那些将工作(错别字 - 属性是长度,并且
你应该检查它是0,而不是大于0)。你
可能会发现后者更具可读性。前者可能会略微提高效率,但坦率地说,在大多数情况下它不会相当于一个很好的价值。
-
Jon Skeet - < sk *** @ pobox.com>
http://www.pobox.com/~skeet
如果回复该群组,请不要给我发邮件
你也可以把它比作string.Empt
Vicky写道:
检查空白字符串的更好方法是
strvar.lenght> 0
strvar ==""
或其他什么
Thnaks
我使用:
strvar == string.Empty
没有特别的原因。
What is the better way of checking blank string is it
strvar.lenght > 0
or
strvar == ""
or something else
Thnaks
Vicky <vi***@hh.com> wrote:What is the better way of checking blank string is it
strvar.lenght > 0
or
strvar == ""
or something else
Either of those will work (typos aside - the property is Length, and
you should be checking for it being 0, not being greater than 0). You
may find the latter more readable. The former is likely to be slightly
more efficient, but frankly it''s not going to amount to a great
difference in most cases.
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
You can also compare it to string.Empt
Vicky wrote:
What is the better way of checking blank string is it
strvar.lenght > 0
or
strvar == ""
or something else
Thnaks
I use:
strvar == string.Empty
for no particular reason.
这篇关于检查空白字符串的更好方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!