How to Reverse a String in C# .Net
Step :-1
- Open Microsoft Visual Studio.
- Then go to to "File" -> "New" -> "Project..." then select Visual C# -> Windows -> Console application.
Then Write the Code For The Reverse a String.
----------------------------------------------------------------------------------------------------------------------
using System;
namespace ReverseAString
{
class Program
{
static void Main(string[] args)
{
string Str, Revstr = "";
int Length;
Console.Write("Enter A String : ");
Str = Console.ReadLine();
Length = Str.Length - 1;
while (Length >= 0)
{
Revstr = Revstr + Str[Length];
Length--;
}
Console.WriteLine("Reverse String Is {0}", Revstr);
Console.ReadLine();
}
}
}
namespace ReverseAString
{
class Program
{
static void Main(string[] args)
{
string Str, Revstr = "";
int Length;
Console.Write("Enter A String : ");
Str = Console.ReadLine();
Length = Str.Length - 1;
while (Length >= 0)
{
Revstr = Revstr + Str[Length];
Length--;
}
Console.WriteLine("Reverse String Is {0}", Revstr);
Console.ReadLine();
}
}
}
--------------------------------------------------------------------------------------------------------
Source-Code ImageStep :-3
Run This Application...
Output :- Enter A String :- DOTNET TRICKS BY VICKY RAJ
Reverse String Is :- JAR YKCIV YB SKCIRT TENTOD
RESULT:-
Thank You For Visit Here !! |
No comments:
Post a Comment