Detect a NULL string

Discussion in 'ASP .Net' started by John Smith, Dec 1, 2003.

  1. John Smith

    John Smith Guest

    How can I detect a NULL string using C# ?
    Thanks.
     
    John Smith, Dec 1, 2003
    #1
    1. Advertising

  2. John Smith wrote:
    > 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)
     
    Frank Oquendo, Dec 1, 2003
    #2
    1. Advertising

  3. 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!
    **********************************************************************
    "John Smith" <> wrote in message
    news:%...
    > How can I detect a NULL string using C# ?
    > Thanks.
    >
     
    Cowboy \(Gregory A. Beamer\), Dec 1, 2003
    #3
  4. Are you trying to test onde columns returned from database?
    You can use the function isDbNUll(FIELD)


    Steven Alexander

    >-----Original Message-----
    >How can I detect a NULL string using C# ?
    >Thanks.
    >
    >.
    >
     
    Steven Alexander, Dec 1, 2003
    #4
  5. John Smith

    Flare Guest

    > >How can I detect a NULL string using C# ?

    if you mean an empty string.

    if( aString == string.empty )
     
    Flare, Dec 1, 2003
    #5
  6. John Smith

    John Smith Guest

    This is the one I looking for: if (myString == null).
    Thanks.
    Q

    Frank Oquendo wrote:

    > John Smith wrote:
    >
    >>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 == "")
    >
     
    John Smith, Dec 1, 2003
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    16
    Views:
    7,437
    Mike Schilling
    Oct 12, 2005
  2. Replies:
    5
    Views:
    27,608
    Mike Schilling
    Mar 29, 2006
  3. Dennis Allison

    interpreting a null pointer as an empty (null string)

    Dennis Allison, Mar 5, 2004, in forum: C Programming
    Replies:
    11
    Views:
    833
    Derk Gwen
    Mar 6, 2004
  4. Jiho Han
    Replies:
    13
    Views:
    677
    John Saunders
    Jul 29, 2006
  5. ssylee
    Replies:
    4
    Views:
    521
    CBFalconer
    Aug 12, 2008
Loading...

Share This Page