I've three three textBox, textBoxLectura1, textBoxLectura2 and textBoxLectura3. When someone clicks on the button button3 I want just to print the entries the user has written.
I made this code and works perfect. I would like to know if there's a more elegant/efficent way to do it without using so many if statements. I would like to maintain the arrayList structure.
private void button3_Click(object sender, EventArgs e) { ArrayList myarray2 = new ArrayList(); if (string.IsNullOrWhiteSpace(textBoxLectura1.Text) == false) { myarray2.Add(textBoxLectura1.Text); } if (string.IsNullOrWhiteSpace(textBoxLectura2.Text) == false) { myarray2.Add(textBoxLectura2.Text); } if (string.IsNullOrWhiteSpace(textBoxLectura3.Text) == false) { myarray2.Add(textBoxLectura3.Text); } if (myarray2.Count > 0) { foreach (string values in myarray2) { Console.WriteLine(values ); } } else { MessageBox.Show("no entrys"); } }
code reviewsite. I will use that next time.