ToUpper converts any lowercase characters in a string to uppercase. ToLower converts any uppercase characters in a string to lowercase:
'aBc'.ToUpper() # Returns ABC 'AbC'.ToLower() # Returns abc
Considering that the methods discussed here are case sensitive, converting a string to a known case may be an important first step. For example:
$string = 'AbN' $string = $string.ToLower() $string = $string.Replace('n', 'c')
The ToTitleCase is not a method of the String object. It is a method of the System.Globalization.TextInfo class. The ToTitleCase method performs limited culture-specific capitalization of words:
PS> (Get-Culture).TextInfo.ToTitleCase('some title')
Some Title
As this is not a static method, the TextInfo object must be created first. This object cannot be directly created. TextInfo can be obtained via the System.Globalization.CultureInfo object, this object is returned by the Get-Culture command.
The same TextInfo object may also be accessed using the host automatic variable:
$host.CurrentCulture.TextInfo.ToTitleCase('another title')
The ToTitleCase method will not convert words that are entirely uppercase. Uppercase words are considered to be acronyms.