ToUpper, ToLower, and ToTitleCase

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, ...

Get Mastering Windows PowerShell Scripting - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.