Reverse number

Posted by anwarbesa-15403 under C# category on | Points: 40 | Views : 1441
Hi.. you will make new windows form application and put one label named (Enter The Number) and put text box for it.. another label named(The Reverse Number) and put text box for it.. and put a button named(Reverse)..

Now,double click on the button and write this code:

int Number = Convert.ToInt32(textBox1.Text);
int r,x = 0;
r = Number%10;
Number = Number/10;
x = r+x*10;
textBox2.Text = x.ToString();
MessageBox.Show("Reverse Done Successfully");

I wish this is be helpful

Thanks and regards

Comments or Responses

Posted by: sankarmjlive-12768 on: 5/7/2012 Level:Starter | Status: [Member] | Points: 10
Dear Anwar,

Writing such a long snippet why don't yo try this below line:

TextBox2.Text = new string(TextBox1.Text.ToCharArray().Reverse().ToArray());

supports alpha numeric & special characters.
Thank you

Posted by: anwarbesa-15403 on: 5/10/2012 Level:Starter | Status: [Member] | Points: 10
Dear Shankar

you are right, but I have n't good experience in programming with dotnet and in programming in general so I write this code as a try..

Thank you so much and I will learn from you ^_^

Login to post response