- Back to Home »
- C# »
Posted by : Jebastin
Tuesday, 7 January 2014
The following C# code is used to convert the first character of a string into upper case.
- static string UppercaseFirst(string s)
- {
- // Check for empty string.
- if (string.IsNullOrEmpty(s))
- {
- return string.Empty;
- }
- // Return char and concat substring.
- return char.ToUpper(s[0]) + s.Substring(1);
- }