Tuesday, March 24, 2009

capitalize first letter word C#

Just a quickie not this can be really helpful for displaying string properly.

string strSomething="PLEASE CAPITALIZE THE FIRST LETTER OF EVERY WORD"
or
string strSomething="please capitalize the first letter of every word"

System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(strSomething.ToLower())

the result
"Please Capitalize The First Letter Of Every Word"

DotNetNuke Custom Module Development

3 comments:

Tariq Hussein said...

Very nice! Thanks for the tip!

Tariq Hussein said...

Oh before I forget, this also works with ASP.NET 1.1 (my host doesn't support anything higher :().

Anonymous said...

Thanks !!