What is String Title case in C#?

CsharpProgrammingServer Side Programming

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);
raja
Published on 10-Aug-2018 11:32:27
Advertisements