我有一个从文本文件中获取其值的数组。每一行都是一个数组值。我试图让每个数组值进入列表框。如将数组值返回到列表框(C#)
[0] - Hello
[1] - Goodbye
,并在列表框中,第一个选项会打招呼,第二个会再见等
文本文件是为你好,再见的分离式线
继承人我的代码从文本文件中的数组进行排序:
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();
这是我的列表框代码:
this.listBox1.Items.AddRange(new object[] {
// Values go here
// i want the arrays here, so that its like "hello", "goodbye",
});
非常感谢帮助。 我使用微软的Visual Studio 2010中