How to reverse a string?
public String
ReverseAstirng(String
x)
{
char[]
arr = x.ToCharArray();
int
leng = arr.Length;
string rev="";
for
(int i = arr.Length-1; i >=0 ;
i--)
{
rev = rev + arr[i].ToString();
}
return rev;
}
static void Main(string[] args)
{
Program p1 = new Program();
Console.WriteLine(" How to reverse a string ? ");
Console.WriteLine("Reverse String = "+ p1.ReverseAstirng("shivKumar"));
Console.ReadLine();
}
Reverse String = ramuKvihs
No comments:
Post a Comment