Nitya1
(Nitya Tomar)
March 21, 2023, 8:00pm
1
There are many ways through which we can reverse a string but I have come up with a single line of code through which we can easily achieve this.
Formula to reverse a string is-
string_tobe_reversed.AsEnumerable.Reverse.ToArray
Here, in the above formula-
Replace the string_tobe_reversed with your string.
It would be return array of char.
Lets see now the implementation in UiPath *
Step 1:- Drag an assign activity and pass a value that you like to reverse.
Step 2:- Drag another assign activity and apply the formula to reverse the string.
Step 3:- Drag message box and print the result.
Step 4:- Run the workflow now.
I hope you enjoyed the article!
Happy Automation!!
2 Likes
what if there is a requirement to reverse the string without using function?
string.Join(“”,str_text.ToCharArray.Reverse)
I tried doing this method but it says
For Each: Object reference not set to an instance of an object.
please check if your variable which you are trying to reverse is having some value or it is null… in general this error comes when the variable is having null value
Check this xaml for your reference
Sequence21.xaml (12.3 KB)
5 Likes
Thank you so much it worked I tried to do it with both methods but in real time do we need to do string reverse?
It depends on your requirement whether to do string reverse or not