DCSIMG
.Net Tip: Convert a String to Title Case - IronShay

.Net Tip: Convert a String to Title Case

If you have a string like "hello world" and you want to use it in a title, you'll probably need to convert this string to "Hello World". The .Net framework gives us this ability out-of-the-box using the TextInfo.ToTitleCase method:

string helloWorld = "hello world";

Console.WriteLine(System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(helloWorld));

This will end up printing "Hello World" on the screen.

Enjoy,
Shay.

Published Thursday, September 11, 2008 6:56 AM by shayf

Comments

# re: .Net Tip: Convert a String to Title Case

nice :),

but the punch line is cut...

.CurrentCulture.TextInfo.ToTitleCase(helloWorld));

Thursday, September 11, 2008 7:26 AM by Avi Pinto

# re: .Net Tip: Convert a String to Title Case

Nice tip

Thursday, September 11, 2008 10:10 AM by Rotem Bloom

Leave a Comment

(required) 
(required) 
(optional)
(required) 

Enter the numbers above: