Detect a NULL string

F

Frank Oquendo

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)
 
C

Cowboy \(Gregory A. Beamer\)

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!
**********************************************************************
 
S

Steven Alexander

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


Steven Alexander
 
F

Flare

How can I detect a NULL string using C# ?

if you mean an empty string.

if( aString == string.empty )
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top