Last active
December 17, 2015 22:49
-
-
Save maxclaus/5685316 to your computer and use it in GitHub Desktop.
Capitalise just the first letter of the whole sentence
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
private string Capitalise(string str) | |
{ | |
if(String.IsNullOrEmpty(str)) | |
return string.Empty; | |
var firstLetter = string.Empty; | |
if(str.Length > 0) | |
firstLetter = Char.ToUpper(str[0]); | |
return (str.Length == 1) ? firstLetter : firstLetter + str.Substring(1).ToLower(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment