display reverse number using c#

Gow.net
Posted by Gow.net under C# category on | Points: 40 | Views : 2916
static void Main(string[] args)
{
string inp = "1234567890";

char[] outp = inp.ToCharArray();

Array.Reverse(outp);

foreach (var item in outp)
{

Console.Write(item);

}

}


output:0987654321

Comments or Responses

Posted by: Raj_Chennai on: 4/17/2012 Level:Starter | Status: [Member] | Points: 10
hi it is not necessary to write this code
foreach (var item in outp)

{
Console.Write(item);
}

since the value in outp is already reversed so its not necessary to use the above code to return the value just use
Console.Write(outp);

Login to post response