110,532
社区成员
发帖
与我相关
我的任务
分享
int num0;
string sc = null;
string[] wc = new string[1000];
string filePath = Application.StartupPath + @"\word.txt";
using (StreamReader sr = new StreamReader(filePath, System.Text.Encoding.GetEncoding("gb2312")))
{
while ((sc = sr.ReadLine()) != null)
{
wc[num] = sc;
num++;
if (num > 300) {sr.Close(); }
}
}
int index = 0;
textBox.Text = wc[index];
...
// 在显示下一条按钮的Click事件中
index++;
textBox.Text = wc[index];
if(index > 300) return;// 读取的时候只要300条,这边可以按需要处理
//index和wc提到外部就可以了