IntroductionIn this snippet, I will show how to print a string in reverse using C# or VB.NET.I have read in forums there is many users asked this question. You can implement this with few lines code in C# or VB.NET. C# Code using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string reverse = "Hello World";
char[] printarray = reverse.ToCharArray();
Array.Reverse(printarray);
Console.WriteLine(new string(printarray));
}
}
}
Output dlroW olleH VB.NET Code Namespace ConsoleApplication1
Class Program
Private Shared Sub Main(args As String())
Dim reverse As String = "Hello World"
Dim printarray As Char() = reverse.ToCharArray()
Array.Reverse(printarray)
Console.WriteLine(New String(printarray))
Console.ReadLine()
End Sub
End Class
End Namespace
Output dlroW olleH I hope this is helps.thank you reading. |