Monday, 7 May 2012

Beginning .Net , C# Tips : Make First Letter of each word capital

There is a situation where you need to capital first letter of each word.
You can also say that Title Case to string.
Here are useful code snippets for this.

C# Example :
string strSample = "this is a sample string.";
Response.Write( System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(strSample));


Output :
This Is A Sample String.


VB.net Example :
Dim strSample As String = "this is a sample string."
Response.Write(System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(strSample))


Output :
This Is A Sample String.

No comments:

Post a Comment