Original Post
My job at the University of Iowa is to computerize certain psychological experiments that used to be performed by hand. Part of the job is to allow the experimenters to alter the instructions or parameters of the program via text files. Now, I'm writing a method that reads input from a text file line by line and prints it all out to a MessageBox so the user can read it (the user is required to confirm that they understand the instructions, so I thought this would be the ideal way to do this). Since I won't know how many lines the experimenters might change the instructions to, I decided to use an ArrayList. Here's some code: I proposed to use instructions.ToString() to output the contents, but all that gets output is "System.Collections.ArrayList", and for some reason when I press the OK button, it beeps again and I have to press it a second time. Any help would be greatly appreciated, either in coming up with a better way to use the ArrayList, or a completely new way to display the instructions altogether. Many thanks in advance, and ratings will be given to those kindhearted enough to help. EDIT: Silly me, nevermind the part about calling up the MessageBox twice. I forgot that the program runs in two sections that use the same method. [Edited by - FinalMinuet on April 17, 2006 10:44:46 PM]
StreamReader input = new StreamReader(@"gain.txt");
string lineIn;
ArrayList instructions = new ArrayList();
do
{
/* Grab the line from the file */
lineIn = input.ReadLine();
/* Save it to the ArrayList */
instructions.Add(lineIn);
} while (lineIn != null);
/* Display the instructions in the MessageBox */
MessageBox.Show(instructions.ToString(), "Instructions: Please Read Carefully!", MessageBoxButtons.OK, MessageBoxIcon.Information);