Skip to content

Instantly share code, notes, and snippets.

@BrunoVT1992
Created May 13, 2016 13:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BrunoVT1992/b372cc514d86ffb32a7c757f5ad60529 to your computer and use it in GitHub Desktop.
Save BrunoVT1992/b372cc514d86ffb32a7c757f5ad60529 to your computer and use it in GitHub Desktop.
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