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
Printable View
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
use reverse function
[QUOTE=bsrreddy;21690]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[/QUOTE]
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;
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.
[QUOTE=bsrreddy;21690]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[/QUOTE]
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;
}
}