locked
Null Values? RRS feed

  • Question

  • User-769178954 posted

    Hi --

    I would like to convert the following

            public static String CleanEmptyString(String value)
            {
    
                if(!String.IsNullOrEmpty(value))
                    value = value.Replace("\0", String.Empty);
    
    
                return String.IsNullOrEmpty(value) ? String.Empty : value;
            }


    ...and have it return a SPACE rather than a null value.  I realize this is fairly simple.  Can someone help me out? 

    Thanks.

    Cindy

    Tuesday, December 18, 2012 4:58 AM

Answers

  • User-837620913 posted

    Just change the return statement to this:

    return String.IsNullOrEmpty(value) ? " " : value;



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, December 18, 2012 5:11 AM

All replies

  • User-837620913 posted

    Just change the return statement to this:

    return String.IsNullOrEmpty(value) ? " " : value;



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, December 18, 2012 5:11 AM
  • User-1716253493 posted
    returnString.IsNullOrEmpty (value) ? " " : value;
    Tuesday, December 18, 2012 5:22 AM