Convert all first letter to upper case, rest lower for each word

mrblah picture mrblah · Dec 22, 2009 · Viewed 130.7k times · Source

I have a string of text (about 5-6 words mostly) that I need to convert.

Currently the text looks like:

THIS IS MY TEXT RIGHT NOW

I want to convert it to:

This Is My Text Right Now

I can loop through my collection of strings, but not sure how to go about performing this text modification.

Answer

jspcal picture jspcal · Dec 22, 2009
string s = "THIS IS MY TEXT RIGHT NOW";

s = System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(s.ToLower());