Convert string into title case in c#

The System.String class contains methods ‘ToUpper’ and ‘ToLower’ which convert the string to Uppercase and Lowercase. But String class does not have the Title Case conversion.

‘TextInfo’ class provide this method. It is in System.Globalization.

using System.Globalization;
TextInfo myText = System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo;
string sample = "this IS a blog for net";
string titleCase = myTextInfo.ToTitleCase(sample);
Response.Write(titleCase);

Output : This Is A Blog For Net