【发布时间】:2012-10-02 18:40:43
【问题描述】:
这是我的代码:
namespace Class_Properties {
public partial class Form1 : Form {
private string firstHeight1 = "";
public int firstHeight {
get {
return Convert.ToInt32( firstHeight1 );
}
}
public Form1() {
InitializeComponent();
}
private void button1_Click( object sender, EventArgs e ) {
firstHeight1 = textBox2.Text;
Form2 secondForm = new Form2();
secondForm.Show();
}
}
}
然后是另一个类:
namespace Class_Properties {
public partial class Form2 : Form {
public Form2() {
InitializeComponent();
Form1 mainWindow = new Form1();
this.Height = mainWindow.firstHeight;
}
}
}
当我运行时,我输入200 作为textbox2 的值并单击button1,然后Visual Studio 会出现以下异常:
我可以做些什么来解决这个错误?
【问题讨论】:
标签: c# winforms exception types compiler-errors