Hi,
Which one of these below two is a better way to find out if the string is of
zero length?
string.Length == 0
or
string.Length < 0
Alwin S. 8 1785
I meant...
string.Length == 0
or
string.Length < 1
"Al Sav" wrote: Hi, Which one of these below two is a better way to find out if the string is of zero length?
string.Length == 0 or string.Length < 0
Alwin S.
I meant...
string.Length == 0
or
string.Length < 1
"Al Sav" wrote: Hi, Which one of these below two is a better way to find out if the string is of zero length?
string.Length == 0 or string.Length < 0
Alwin S.
Well the first is clearer although I prefer
s == string.Empty
What do you mean by "better"? If you mean in terms of performance then in any application, this sort of micro-optimization is irrelevent. Write the code with clarity, performance test the application and if there are issues, profile the aplication and find out where the real bottlenecks are.
Regards
Richard Blewett - DevelopMentor http://www.dotnetconsult.co.uk/weblog http://www.dotnetconsult.co.uk
nntp://news.microsoft.com/microsoft.public.dotnet.languages.csharp/<A2**********************************@microsoft.co m>
I meant...
string.Length == 0
or
string.Length < 1
Well the first is clearer although I prefer
s == string.Empty
What do you mean by "better"? If you mean in terms of performance then in any application, this sort of micro-optimization is irrelevent. Write the code with clarity, performance test the application and if there are issues, profile the aplication and find out where the real bottlenecks are.
Regards
Richard Blewett - DevelopMentor http://www.dotnetconsult.co.uk/weblog http://www.dotnetconsult.co.uk
nntp://news.microsoft.com/microsoft.public.dotnet.languages.csharp/<A2**********************************@microsoft.co m>
I meant...
string.Length == 0
or
string.Length < 1
Al,
I tend to use <1 where applicable, since I program in several languages that
are not all compatable in thier return values. In this case Length cannot be
< 0, but that is not the case for length in everything I use.
"Al Sav" wrote: Hi, Which one of these below two is a better way to find out if the string is of zero length?
string.Length == 0 or string.Length < 0
Alwin S.
Al,
I tend to use <1 where applicable, since I program in several languages that
are not all compatable in thier return values. In this case Length cannot be
< 0, but that is not the case for length in everything I use.
"Al Sav" wrote: Hi, Which one of these below two is a better way to find out if the string is of zero length?
string.Length == 0 or string.Length < 0
Alwin S. http://www.dotnet247.com/247referenc...23/118322.aspx
ShaneB
"Les" <Le*@discussions.microsoft.com> wrote in message
news:0B**********************************@microsof t.com... Al, I tend to use <1 where applicable, since I program in several languages that are not all compatable in thier return values. In this case Length cannot be < 0, but that is not the case for length in everything I use.
"Al Sav" wrote:
Hi, Which one of these below two is a better way to find out if the string is of zero length?
string.Length == 0 or string.Length < 0
Alwin S. http://www.dotnet247.com/247referenc...23/118322.aspx
ShaneB
"Les" <Le*@discussions.microsoft.com> wrote in message
news:0B**********************************@microsof t.com... Al, I tend to use <1 where applicable, since I program in several languages that are not all compatable in thier return values. In this case Length cannot be < 0, but that is not the case for length in everything I use.
"Al Sav" wrote:
Hi, Which one of these below two is a better way to find out if the string is of zero length?
string.Length == 0 or string.Length < 0
Alwin S. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Karl Ebener |
last post by:
Hi!
I asked a similar question before but then changed everything to using
char-Arrays instead of the string class, but I would rather not do this
again.
So, does anyone know of a...
|
by: Al Sav |
last post by:
Hi,
Which one of these below two is a better way to find out if the string is of
zero length?
string.Length == 0
or
string.Length < 0
Alwin S.
|
by: genc_ymeri |
last post by:
Hi over there,
Propably this subject is discussed over and over several times. I did google
it too but I was a little bit surprised what I read on internet when it
comes 'when to use what'.
Most...
|
by: ventos |
last post by:
First of all, ive been trying to learn c++ for a couple of days ;)
Problem i need to strip http links from string
code:
string replaceAll(string s, string f, string r) {
unsigned int found...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |