Skip to content

Instantly share code, notes, and snippets.

@icalderond
Created July 7, 2016 21:53
Show Gist options
  • Save icalderond/22869f9c1ec822d1945be455b140e84c to your computer and use it in GitHub Desktop.
Save icalderond/22869f9c1ec822d1945be455b140e84c to your computer and use it in GitHub Desktop.
Convertir la primera letra en Mayuscula
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