PowerShell for Windows Admins

Nov 29 2018   1:01PM GMT

Reverse a string

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

Tags:

I sort of brushed over it on my last post but this is how you reverse a string.

The code is at https://github.com/RichardSiddaway/Blogcode/blob/master/stringtechniques.ps1

Take the input string and turn it into an array of chars. Use the reverse static method of the array class to reverse the array. Other useful array methods can be found in the documentation – https://docs.microsoft.com/en-us/dotnet/api/system.array?redirectedfrom=MSDN&view=netframework-4.7.2

-Join is used to stitch the reversed char array back into a string.

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: