Wednesday, November 12, 2014

String into Lower Upper or Title Case using C#

TextInfo class provides very useful string casing functions. These functions can be used to change case of a string into
  1. Lower Case
  2. Upper Case and
  3. Title Case
TextInfo class is available under System.Globalization namespace. TextInfo object can be initiated from CultureInfo by using following ways.
  1. CultureInfo.CurrentCulture.TextInfo
  2. new CultureInfo("en-US",false).TextInfo

String to Lower Case:
TextInfo class provides ToLower function to convert a string into lower case. Its usage is illustrated in code snippet available in end of this article.

String to Upper Case:
TextInfo class provides ToUpper function to convert a string into lower case. All characters in string are converted into upper case. Its usage is illustrated in code snippet available in end of this article.

String to Title Case:
TextInfo class provides ToTitleCase function to convert a string into a Title case. It converts first character of each word into upper case and remaining characters of each word into lower case. Its usage is illustrated in code snippet available in end of this article.

Code


Output



No comments:

Post a Comment