我得到
System.NullReferenceException:'对象引用未设置为 对象的实例。'
试图从文件中加载数据。
我知道文件可以很好地加载,但是在打印标签时却出现了错误
string latadata = lata.ReadLine();
while (latadata != null) {
productLataArray[init] = latadata;
// print product name and price
this.Controls["nameLbl" + i].Text =
productLataArray[init].Substring(productLataArray[init].Length -
productLataArray[init].Length, productLataArray[init].Length - 4); // PRINT NAME
this.Controls["numLbl" + i].Text =
productLataArray[init].Substring(productLataArray[init].Length - 4); // PRINT PRICE
latadata = lata.ReadLine();
init += 1;
i += 1;
}