The ToTitleCase method is used to capitalize the first letter in a word. Title case itself means to capitalize the first letter of each major word.
Let us see an example to get the title case −
Example
using System;
using System.Globalization;
class Demo {
static void Main() {
string str = "jack sparrow";
string res = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(str);
Console.WriteLine(res);
}
}Output
Jack Sparrow
Above, we have set the input string to the ToTitleCase() method. The CultureInfo.TextInfo property is used to provide the culture-specific casing information for strings −
CultureInfo.CurrentCulture.TextInfo.ToTitleCase(str);