c# convert first letter to uppercase code example
Example 1: c# capitalize first letter
string text = "john smith";
// "John smith"
string firstLetterOfString = text.Substring(0, 1).ToUpper() + text.Substring(1);
// "John Smith"
// Requires Linq! using System.Linq;
string firstLetterOfEachWord =
string.Join(" ", text.Split(' ').ToList()
.ConvertAll(word =>
word.Substring(0, 1).ToUpper() + word.Substring(1)
)
);
Example 2: c# make first letter uppercase
System.Console.WriteLine(char.ToUpper(str[0]) + str.Substring(1));