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 1781
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: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |