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
- Input variable is var1.
- create variable , var2 with datatype System.Collections.Generic.IEnumerable<system.char>
- Assign var2 = var1.reverse
- Assign var1= string.join(“”,var2).tostring
you will get the reverse string
2 Likes
Hi,
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
5 Likes