Reverse a string

How to reverse a string with out using reverse method? Suppose var1=‘abcdefg’ i need output as ‘gfedcba’ with out using reverse method?

you can use Do While loop and concatenate string in reverse order.

Convert string into character array

char[] characters = var1.ToCharArray

And then loop and join the characters in reverse order.

1 Like
  1. Input variable is var1.
  2. create variable , var2 with datatype System.Collections.Generic.IEnumerable<system.char>
  3. Assign var2 = var1.reverse
  4. Assign var1= string.join(“”,var2).tostring
    you will get the reverse string


There is a .net builtin function available to reverse a string without any looping statements.

Try like this StrReverse(YourTestString) assign this to a new string variable

For more details refer this link Strings.StrReverse(String) Method (Microsoft.VisualBasic) | Microsoft Learn



Here is a detailed article on that :slight_smile:
# How To Reverse A String In UiPath


1 Like