Stuart Sillitoe

public static string UcFirst(this string theString)
        {
            if ( string.IsNullOrEmpty(theString) )
            {
                return string.Empty;
            }

            char[] theChars = theString.ToCharArray();
            theChars[0] = char.ToUpper(theChars[0]);

            return new string(theChars);

        }
Example:
"some string".UcFirst();

OR

string str = "a string";

str.UcFirst();

Description

Emulation of PHPs ucfirst()

Details

Double click on the code to select all.

 

;