rick graner dot com

developers! developers! developers!
musings of my creative and technical writing

Uppercase First Method in CSharp

C# method to uppercase the first letter of a passed in string.

I know that this method is out on the interwebs somewhere so if anyone knows, please share with me so I can give credit where credit is due.

I am starting to share all of my little helper methods online so I never forget 🙂

private static string UppercaseFirst(string s)
{
    // Check for empty string.
    if (string.IsNullOrEmpty(s))
    {
        return string.Empty;
    }
    // Return char and concat substring.
    return char.ToUpper(s[0]) + s.Substring(1);
}