What you want to see on DotNetFunda.com ?
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 10426 |  Welcome, Guest!   Register  Login
 Home > Code Snippets > C# > Reverse number ...
Anwarbesa@Yahoo.Com

Reverse number

 Code Snippet posted by: Anwarbesa@Yahoo.Com | Posted on: 5/4/2012 | Category: C# Codes | Views: 665 | Status: [Member] | Points: 40 | Alert Moderator   


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;
while(Number>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
Anwar

C is a sea.. and you are the sea of C!

Thanks & Regards
Found interesting? Add this to:


 Responses

Sankarmj@Live.Com
Posted by: Sankarmj@Live.Com | Posted on: 5/7/2012 | Level: Starter | Status: [Member] | Points: 10 | Alert Moderator 

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


Shankar.M
Think more... Code less

Anwarbesa@Yahoo.Com
Posted by: Anwarbesa@Yahoo.Com | Posted on: 5/10/2012 | Level: Starter | Status: [Member] | Points: 10 | Alert Moderator 

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 ^_^


C is a sea.. and you are the sea of C!

Thanks & Regards

>> Write Response - Respond to this post and get points

More codes snippets

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/24/2013 11:32:34 PM