Pya*_*dav 2 c# programming-languages c#-4.0
class Plane
{
public event EventHandler Land;
protected void OnLand()
{
if ( null != Land )
{
Land( this, null );
}
}
}
Run Code Online (Sandbox Code Playgroud)
它是事件处理程序的最佳实践:
EventHandler temp = Land;
if ( null != temp )
{
temp( this, null );
}
Run Code Online (Sandbox Code Playgroud)
这真的有必要吗?在什么情况下可能会与Land不同?