Created
July 7, 2016 21:53
-
-
Save icalderond/22869f9c1ec822d1945be455b140e84c to your computer and use it in GitHub Desktop.
Convertir la primera letra en Mayuscula
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
public static string UppercaseFirst(string text) | |
{ | |
var s = text.TrimEnd().TrimStart().ToLower(); | |
// Check for empty string. | |
if (string.IsNullOrEmpty(s)) | |
return string.Empty; | |
var arr = s.Split(' '); | |
foreach (var item in arr) | |
s = s.Replace(item, char.ToUpper(item[0]) + item.Substring(1)); | |
// Return char and concat substring. | |
return s; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment