Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reversing numbers

Status
Not open for further replies.

Grizant

Programmer
Oct 6, 2002
7
US
If you ask for an inputed number which is classified as int, how would you reverse the order of those numbers using functions. EX) 8374 to 4738.
 
You could always use the ToString method of the Int class and then using basic string manipulation in a For loop, reverse it that way.
 
Try this:
Code:
String MyString = new String("4567");
Array myArray=Array.CreateInstance(typeof(Char), 4);
for (int i = myArray.GetLowerBound(0); i <= myArray.GetUpperBound(0); i++) {
   myArray.SetValue(MyString.Char(i), i);
}
Array.Reverse(myArray);

Chip H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top