【发布时间】:2010-02-15 00:53:51
【问题描述】:
我有一个将事件附加到表单的代码。
this.form.Resize += new EventHandler(form_Resize);
如您所见,这是由+= 完成的。
如果上面的代码被执行了两次或多次,
像这样:
this.form.Resize += new EventHandler(form_Resize);
this.form.Resize += new EventHandler(form_Resize);
this.form.Resize += new EventHandler(form_Resize);
this.form.Resize += new EventHandler(form_Resize);
this.form.Resize += new EventHandler(form_Resize);
回调方法是否被多次附加?
方法会被调用多少次
form_Resize?
如果一个事件的回调方法被多次分配给同一个对象,它会被多次执行吗?
【问题讨论】:
-
不,我不知道。我虽然优化器会看到这个额头并且不会多次附加。