Uppercase First Method in C#

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);

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.