以下代码来自Josh Smith的MVVM示例:
/// <summary>
/// Raised when this workspace should be removed from the UI.
/// </summary>
public event EventHandler RequestClose;
void OnRequestClose()
{
//if (RequestClose != null)
// RequestClose(this, EventArgs.Empty);
EventHandler handler = this.RequestClose;
if (handler != null)
handler(this, EventArgs.Empty);
}
这些被注释的行是我添加的。我的问题是,这些被注释的行会和未被注释的行做同样的事情,对吗?那么为什么要创建另一个EventHandler引用呢?或者我漏掉了什么?谢谢。