Geeks Talk

Prepare for your Next Interview


Welcome to the Geeks Talk forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

Code to display input in reverse

This is a discussion on Code to display input in reverse within the C# forums, part of the Software Development category; Dear fnds, i have 2 text boxes 1 button, my question is i am entering (example 123 or abc ) in 1st textbox, when i click button then ( 321 ...

Go Back   Geeks Talk > Software Development > C#
Register Blogs FAQ Tag Cloud Calendar Mark Forums Read
  #1 (permalink)  
Old 11-29-2007
Junior Member
 
Join Date: Jul 2007
Posts: 5
Thanks: 0
Thanked 2 Times in 1 Post
bsrreddy is on a distinguished road
Code to display input in reverse

Dear fnds,
i have 2 text boxes 1 button, my question is i am entering (example 123 or abc ) in 1st textbox, when i click button then ( 321 or cba ) will dispaly in 2nd textbox.

please tell how to write code for this.

cheers
Reply With Quote
The Following 2 Users Say Thank You to bsrreddy For This Useful Post:
Sponsored Links
  #2 (permalink)  
Old 11-30-2007
Junior Member
 
Join Date: Sep 2007
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
ajith007 is on a distinguished road
Re: Code to display input in reverse

use reverse function
Reply With Quote
  #3 (permalink)  
Old 11-30-2007
Junior Member
 
Join Date: Nov 2007
Location: india
Posts: 6
Thanks: 1
Thanked 0 Times in 0 Posts
kumaresforu is on a distinguished road
Re: Code to display input in reverse

Quote:
Originally Posted by bsrreddy View Post
Dear fnds,
i have 2 text boxes 1 button, my question is i am entering (example 123 or abc ) in 1st textbox, when i click button then ( 321 or cba ) will dispaly in 2nd textbox.

please tell how to write code for this.

cheers
U can go this way
int a = Textbox1.Text.Length;
string b = "";
for(int i=a;i>0;i--)
{
b = b+""+Textbox1.Text.Substring(i-1, 1).ToString();
}
Textbox2.Text = b;
Reply With Quote
  #4 (permalink)  
Old 11-30-2007
Junior Member
 
Join Date: Nov 2007
Location: Hyderabad
Posts: 12
Thanks: 3
Thanked 2 Times in 1 Post
maverick_dude is on a distinguished road
Lightbulb Re: Code to display input in reverse

I could not find the Reverse function . Though created my own function using a for loop.

private string reverse(string str)
{
string rev = string.Empty;
for (int i=str.Length-1; i>=0;i--)
{
rev += str[i];
}
return rev;

}

try using this.
Reply With Quote
  #5 (permalink)  
Old 07-16-2008
Junior Member
 
Join Date: Jul 2008
Location: Mumbai
Posts: 7
Thanks: 0
Thanked 2 Times in 2 Posts
sudhakarr.net is on a distinguished road
Re: Code to display input in reverse

Quote:
Originally Posted by bsrreddy View Post
Dear fnds,
i have 2 text boxes 1 button, my question is i am entering (example 123 or abc ) in 1st textbox, when i click button then ( 321 or cba ) will dispaly in 2nd textbox.

please tell how to write code for this.

cheers
string s=textBox1.Text;//entered in this textbox1 as 123
int p=s.Length;
if(p!=0)
{
string k;
for(int t=1;t<=p;t++)
{
k=s.Substring(p-t);
textBox2.Text+=k;//you get the reverse order in this text box2
int q=s.Length;
int w=0;
string r=s.Remove(q-1,w+1);
s=r;
}
}
Reply With Quote
The Following User Says Thank You to sudhakarr.net For This Useful Post:
Reply

  Geeks Talk > Software Development > C#

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
I need to reverse the bits in a short integer Geek_Guest C and C++ 2 10-02-2008 10:16 AM
write a program to reverse a string with/with out reverse() method? ramakris143 Java 7 11-24-2007 06:33 AM
reverse number mcamuthu C and C++ 6 08-06-2007 08:16 AM
How do I reverse a string with sql query only? swanand11may SQL 4 07-09-2007 05:15 AM
Need predefined Function or code for Data Display in PHP norman PHP 0 07-17-2006 04:17 PM


All times are GMT -4. The time now is 04:32 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.1
Copyright © 2005 - 2010 GeekInterview.com. All Rights Reserved