Change to TitleCase

As everyone knows, string is a reference types and it stores in heap. Class String has two public functions ToLower() and ToUpper(), to change string cases lower and upper respectively.

Here, i would like to show you how to change string case as TitleCase:

public static string ToTitleCase(string strValue)
//To check whether the given value is null or empty
if (String.IsNullOrEmpty(strValue))
return string.Empty;
else //if not, Change case to TitleCase
CultureInfo info = Thread.CurrentThread.CurrentCulture;
return info.TextInfo.ToTitleCase(strValue);

Hope, the above code will helps you when needs.


No responses found. Be the first to comment...

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: