Masoud A

Masoud A

  • NA
  • 30
  • 18.5k

Add input from Textbox to listbox by using Dynamic array C#

May 13 2015 10:06 PM
Greetings,
I am stuck at this project quite a bit now, was wondering if anyone here can help me out :)
The scenario of this project is  "User gives some value as input by textbox and they'll be added to first listbox "Vertically" by clicking the first button, and after that by clicking second button all of the data will be shown reversely  on second listbox"
here is my code so far:
private void button1_Click(object sender, EventArgs e)
{
string[] n = new string[listBox1.Items.Add(textBox1.Text)];

for ( int i = 0; i < n.Length; i++)
{
n[i] = listBox1.Items[i].ToString();
}

}


private void button2_Click(object sender, EventArgs e)
{

string n = n.Reverse<>;
for(int i = 0; i < n.Length; i++)
{
listBox2.Items[i].ToString();
}
listBox1.Items.Clear();

----------
First button works perfectly however the reversing the array and show it in listbox2 is somehow not working,
Thanks in advance.

Answers (5)