Reverse Parsing an Integer#

Someone asked how to do a reverse parse on an integer, ie. reading it from back to front.  The trick is that you have to convert it into a char array and sinmply reverse that, then rebuild it into an int if necessary once you have it turned around.

int myVal = 84357;

char[] reverse = myVal.ToString().ToCharArray() ;

Array.Reverse(reverse);

StringBuilder Sb = new StringBuilder();

foreach (char letter in reverse)

{

 Sb.Append(letter);

}

Response.Write(Sb.ToString());

10/24/2006 10:17:06 AM (GMT Standard Time, UTC+00:00) #    Comments  |  Trackback

 

All content © 2009, John Timney
On this page
This site
Calendar
<January 2009>
SunMonTueWedThuFriSat
28293031123
45678910
11121314151617
18192021222324
25262728293031
1234567
Archives
Sitemap
Blogroll OPML
Talk to Me

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

Send mail to the author(s) E-mail