Uppercase with null check

 public static String ToUpperCheckForNull(this string input)
        {

            string retval = input;

            if (!String.IsNullOrEmpty(retval))
            {
                retval = retval.ToUpper();
            }

            return retval;

        }
Example:
string g = "potatoe";

return g.ToUpperCheckForNull();

will return "POTATOE"

Description

Converts a string to upper-case but checks for null strings first

Details

Double click on the code to select all.

 

;