I was just wondering how can I print an entire ArrayList in a MessageBox? Here is what I currently have:
ArrayList myData = new ArrayList();
...bunch of Strings added to myData...
private void btnDisplayScores_Click(object sender, EventArgs e)
{
MessageBox.Show(myData); <-----what I need help with
}
You can try converting an obsolete ArrayList to IEnumerable<Object> and then Join items together:
MessageBox.Show(string.Join(Environment.NewLine, myData.OfType<Object>()));
A better design is to change ArrayList to List<Object> (or List<String> if myData should have just String items):
List<Object> myData = new List<Object>();
...
MessageBox.Show(string.Join(Environment.NewLine, myData));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With