To reverse a string in C# or VB.NET you can use the following snippet.

Sample C#

public string Reverse(string input)
{
    var arrayInput = input.ToCharArray();
    Array.Reverse(arrayInput);
    return new string(arrayInput);
}

Sample VB.NET

Public Function Reverse(input As String) As String
	Dim arrayInput = input.ToCharArray()
	Array.Reverse(arrayInput)
	Return New String(arrayInput)
End Function

for more informations take a look at the MSDN: Array.Reverse Method (Array)

One thought on “How to reverse a string in C# or VB.NET”

Leave a Reply