What is String Title case in C#?



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

 Live Demo

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);
Updated on: 2020-06-20T16:31:55+05:30

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements