Answer to Question #37919 in C# for Ravi Patel

Question #37919
string text = TextBox2.Text; string sRaw = text.ToString(); string sClean = sRaw.Replace(",", " "); text = sClean.Trim(); TextBox2.Text = text.ToString(); for (int i = 0; i < text.Length; i++) { if (text.ToString()!="") { ListBox5.Items.Add(Convert.ToString(text[i])); } else { Response.Write("a"); } ListBox5.Items.Add(text.Split("\n")); } I want to move each item of string textbox = "1,21,45,785" into Listbox using this code... please assist me............ Or correct the coding
1
Expert's answer
2013-12-27T11:58:53-0500
Everything is a lot easier:

string[] text = textBox2.Text.Split(',');
foreach (string st in text)
{
if (st!="")
{
listBox5.Items.Add(st.Trim());
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS
paypal