Created
May 13, 2016 13:20
-
-
Save BrunoVT1992/b372cc514d86ffb32a7c757f5ad60529 to your computer and use it in GitHub Desktop.
Converter to capitalize the first character of a string in C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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