Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Format string to title case

How do I format a string to title case?

like image 493
tags2k Avatar asked Aug 03 '08 16:08

tags2k


People also ask

How do you change a string to a title case?

To make titlecased version of a string, you use the string title() method. The title() returns a copy of a string in the titlecase. The title() method converts the first character of each words to uppercase and the remaining characters in lowercase.

How do you convert all strings to title caps in a string array?

Convert all the elements in each and every word in to lowercase using string. toLowerCase() method. Loop through first elements of all the words using for loop and convert them in to uppercase.

How do you convert text to title case in Python?

The String title() method in Python is used to convert the first character in each word to uppercase and the remaining characters to lowercase in the string and returns a new string.

What is title case 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.


1 Answers

Here is a simple static method to do this in C#:

public static string ToTitleCaseInvariant(string targetString) {     return System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(targetString); } 
like image 163
tags2k Avatar answered Oct 31 '22 17:10

tags2k