Click here to Skip to main content
15,878,708 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Hi i want to know how can i contrariwise the number 4digit or 5digit
like this
With Respect
george4986 9-Oct-14 2:31am    
u mean reverse?
Sinisa Hajnal 9-Oct-14 2:48am    
Please do NOT post your questions here before doing some research. This is not free-code service!

Again, simple google query "String.Reverse .net" will get you tons of solutions.
Share this answer
You can do it this way

int i = 1234;
string s = i.ToString();                        // Convert the int to a string
string r = new string(s.Reverse().ToArray());   // Reverse the string
int j = int.Parse(r);                           // Convert the reversed string to an int

Or the one liner
int k = int.Parse(new string(i.ToString().Reverse().ToArray()));
Share this answer
int n = 456;
int getnum= n;
int rev = 0;
   r = getnum% 10;
   rev = rev * 10 + r;
   left = getnum/ 10;  //left = Math.floor(left / 10);
Share this answer
Avenger1 9-Oct-14 2:37am    
what is "r" and "left"?
murkalkiran 9-Oct-14 2:39am    
sorry left is getnum
r is int
Avenger1 9-Oct-14 2:55am    
can you give me a fixed code because it just give me "0" result

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900