Reversing Text Strings

by Jun 18, 2013

Here's a simple trick to reverse a text string:

$text = 'Hello World'

$text = $Text.ToCharArray()
-join $text

The Reverse() method is very useful to reverse the order of any array. Since texts are just character arrays, it can be used to reverse texts. The resulting character array then just needs to be converted back to a string using the operator -join.

Twitter This Tip! ReTweet this Tip!