Detect a NULL string

  • Thread starter Thread starter John Smith
  • Start date Start date
John said:
How can I detect a NULL string using C# ?
Thanks.

Not sure what you mean by a null string so just in case, here's two
options:

Null: if (myString == null)
Empty: if (myString == "")

--
There are 10 kinds of people. Those who understand binary and those who
don't.

http://code.acadx.com
(Pull the pin to reply)
 
Null string, as in char(0) or a string that is null:

if(stringName == null)
{
// you detected a null string
}

char[] charArray = stringName.ToCharArray();

//Assume only one char if it is a null char
if(charArray[0] == 0)
{
// only a null char
}

I am flying by the seat of my pants here, so you may have to alter the code
to get past debug. The theory is sound, however.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

**********************************************************************
Think Outside the Box!
**********************************************************************
 
Are you trying to test onde columns returned from database?
You can use the function isDbNUll(FIELD)


Steven Alexander
 
How can I detect a NULL string using C# ?

if you mean an empty string.

if( aString == string.empty )
 
Back
Top