关于Timer
public partial class Form4 : Form
{
int gap;
Timer newTimer=null; //疑问:是否要设定为null,是否可以定义为Timer newTimer;
public Form4(Timer tm)
{
InitializeComponent();
this.newTimer = tm;
comboBox1.Text = (newTimer.Interval / 60000).ToString();
}
public void button1_Click(object sender, EventArgs e)
{
gap = int.Parse(comboBox1.Text);
newTimer.Interval = (60000 * gap);
this.Close();
}
}
程序运行时大部分时间是正常的,但有一次出现"对象引用设置到对象实例"?,不知是怎么回事?