Thursday, December 23, 2010

Set Title Case

Hi ,
I need to display user name in title case. for example if user enter his first name as mahesh and middle name as kumar and surname as sharma than it should be display as "Mahesh Kumar Sharma".. irrespective of users enter format.
so i need a function which set the initial character of word in large. abc xyx def tuv

ChangeToTitleCase("abc xyx def tuv") should be return Abc Xyz Def Tuv.

The body of function is as follows :

private string ChangeToTitleCase(string inputText)
return Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase((inputText?? string.Empty).ToLower());

Mahesh K Sharma

No comments: