Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Converter to capitalize the first character of a string in C#
namespace CSharp
{
public static class StringConverter
{
public static string Capitalized(string text)
{
if (string.IsNullOrEmpty(text))
{
return text;
}
var chars = text.ToLower().ToCharArray();
chars[0] = char.ToUpper(chars[0]);
return new string(chars);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.