50分求解
private void Form1_Load(object sender, EventArgs e)
{
FileStream FS = new FileStream("c:/trybook/trybook.txt",FileMode.Open);//根据路径创建文件流
StreamReader reader = new StreamReader(FS);//创建读取器
string content = reader.ReadToEnd();//读取全部文件内容
string[] strcontent = Regex.Split(content, "\r\n", RegexOptions.IgnoreCase);//用split方法将字符串拆成数组
int j = strcontent.Length;
for (int i=0;i<j;i++)
{
Label trybookcontent = new Label();//创建新标签
trybookcontent.Name = "lab" + i;
trybookcontent.Text = i.ToString();
this.Controls.Add(trybookcontent);
}
}
运行结果为什么是0。那出错了断点J=4