I have an array that gets its values from a text file. Each line is an array value. I am trying to make each of those array values go into the listbox. Such as
[0] - Hello
[1] - Goodbye
and in the listbox, the first option will be hello, and the second will be goodbye etc.
The text file is Hello and Goodbye on seperated lines
Heres my code to sort the array from the text file:
StreamReader sr = new StreamReader("text.txt");
int counter = 0;
string line;
string[] linea;
linea = new string[100];
while ((line = sr.ReadLine()) != null)
{
linea[counter] = line;
counter++;
}
sr.Close();
And here's my code for the list box:
this.listBox1.Items.AddRange(new object[] {
// Values go here
// i want the arrays here, so that its like "hello", "goodbye",
});
Help is much appreciated. I am using MS Visual Studio 2010.