KeyAdd.Designer.cs
namespace PasswordExpert
{
partial class Key
{
private void InitializeComponent()
{
this.lblNumb = new System.Windows.Forms.Label();
private System.Windows.Forms.Label lblNumb;
this.lblNumb.AutoSize = true;
this.lblNumb.Location = new System.Drawing.Point(123, 27);
this.lblNumb.Name = "lblNumb";
this.lblNumb.Size = new System.Drawing.Size(17, 12);
this.lblNumb.TabIndex = 9;
this.lblNumb.Text = " ";
......
}
......
}
KeyAdd.cs
namespace PasswordExpert
{
public partial class Key : Form
{
string str_temp = this.lblNumb.Text;//这句出错,str_temp是一个测试变量,没有问题。
// lblNumb是lable类型
.......
}
************** 异常文本 **************
System.NullReferenceException: 未将对象引用设置到对象的实例。
这两个文件都是一个命名空间
明明this.lblNumb已经创建,并且有初值( this.lblNumb.Text = " ";)
怎么就说this.lblNumb.Text有问题呢?