suppose we have 2 textbox.
in textbox1 there is name and in textbox2 mobile no.
and output is combination of these 2.
ex..
textbox1.....josop
textbox2.....9970345678
output...
j9o9s7o03p45678
thank you.
How To modify text..
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.

AlanRank #669 · 3.6K reputationPosted Nov 7, 2008, 9:19 AM EST
You can do this (rather messily) with code such as this:
string text1 = textBox1.Text; // "josop"
string text2 = textBox2.Text; // "9970345678"
char[] chars = new char[text1.Length + text2.Length];
chars[0] = text1[0];
chars[1] = text2[0];
chars[2] = text1[1];
chars[3] = text2[1];
chars[4] = text1[2];
chars[5] = text2[2];
chars[6] = text1[3];
chars[7] = text2[3];
chars[8] = text2[4]; // is this the right way around?
chars[9] = text1[4]; // ditto
for(int i = 10; i < chars.Length; i++)
{
chars[i] = text2[i - 5];
}
string output = new string(chars);
string message = String.Format("The combination of '{0}' and '{1}' is '{2}'", text1, text2, output);
MessageBox.Show(message);
However, if you want to do this generally, you'll need to be clear on how many elements of each string are to be interleaved.
Satish KathiRank #8,369 · 223 reputationPosted Nov 7, 2008, 9:44 AM EST
StringBuilder r = new StringBuilder();
int i;
for (i = 0; i < textBox1.Text.Length; i++)
{
r.Append(textBox1.Text.Substring(i, 1));
if (textBox2.Text.Length > i)
{
r.Append(textBox2.Text.Substring(i, 1));
}
}
if (textBox2.Text.Length > i)
r.Append(textBox2.Text.Substring(i));
label2.Text = r.ToString();
shashank kale8 reputationPosted Nov 8, 2008, 7:45 AM EST