Exercise
Function Reverse, recursive
Objetive
Write a Visual Basic (VB.Net) program that uses recursion to reverse a string of characters (for example, from "Hello" it would return "olleH").
Code
Imports System
Public Class exercise128
Public Shared Function Reverse(ByVal text As String) As String
If text.Length <= 1 Then Return text
Dim firstLetter As Char = text(0)
Dim rest As String = text.Substring(1)
Return Reverse(rest) & firstLetter
End Function
Public Shared Sub Main(ByVal args As String())
Console.WriteLine(Reverse("Juan"))
End Sub
End Class