Reverse String Program in C#

Advertisements

Prev Tutorial Next Tutorial

Reverse a String Program in C#

To reverse any string we no need any new concept just apply same concept like C and C++ Program.

Formula

Remainder = Number % 10;  
Reverse = (Reverse * 10) + remainder;  
Number = Number / 10; 

Reverse a String Program in C#

using System;  
  
namespace reverseString  
{  
class Program  
{  
static void Main(string[] args)  
{  
string str = "", reverse = "";  
int Length = 0;  
Console.WriteLine("Enter any String: ");  
//Getting String(word) from Console  
str = Console.ReadLine();  
//Calculate length of string str  
Length = str.Length - 1;  
while(Length>=0)  
{  
reverse = reverse + str[Length];  
Length--;  
}  
//Displaying the reverse string  
Console.WriteLine("Reverse String is: {0}",reverse);  
Console.ReadLine();  
 }  
}  
}

Output

Enter any String: Raj
Reverse String is: jaR

Output

Enter any String: Hitesh
Reverse String is: hsetiH

Prev Tutorial Next Tutorial

Advertisements

Buy This Ad Space @$20 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 9999595223

Pure VPN Privide Lowest Price VPN Just @ $1.65. Per Month with Non Detected IP Lowest Price Non Detected IP VPN

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

Download Projects

Google Advertisements


Buy Websites 9999595223

Buy College Projects with Documentation Contact on whatsapp 9999595223. Contact on: hitesh.xc@gmail.com or 9999595223 Try this Keyword C++ Programs

Advertisements