C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Info: Reverse internally rearranges the characters in the array to be in the opposite order.
Finally: You must invoke the String constructor. This converts the reversed character array back into a string.
VB.NET program that reverses strings
Module Module1
Sub Main()
' Test.
Console.WriteLine(Reverse("Codex"))
Console.WriteLine(Reverse("sam"))
Console.WriteLine(Reverse(Reverse("Codex")))
End Sub
''' <summary>
''' Reverse input string.
''' </summary>
Function Reverse(ByVal value As String) As String
' Convert to char array.
Dim arr() As Char = value.ToCharArray()
' Use Array.Reverse function.
Array.Reverse(arr)
' Construct new string.
Return New String(arr)
End Function
End Module
Output
slrep
mas
Codex
However: Even with these constraints, you would likely need to use the String constructor or possibly ToCharArray.
ToCharArrayInstead: You must convert them to character arrays with the ToCharArray function.