Reverse a String

This function returns a string reversed according to the parameter "strToReverse".

VB.NET

''' <summary>
''' Reverses a string.
''' </summary>
''' <param name="strToReverse">The string you'd like to reverse.</param>
''' <returns>The string value of the reversed string.</returns>
''' <remarks></remarks>

Public Function ReverseString(ByRef strToReverse As String) As String
    Dim result As String = ""
    For i As Integer = 0 To strToReverse.Length - 1
        result += strToReverse(strToReverse.Length - 1 - i)
    Next
    Return result
End Function

' Example Usage
MessageBox.Show(ReverseString("Hello World!"))

See Also

</DIC> Submission - http://www.dreamincode.net/code/snippet1521.htm

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License