小编Pya*_*dav的帖子

c#语言中的事件处理程序

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不同?

c# programming-languages c#-4.0

2
推荐指数
1
解决办法
269
查看次数

标签 统计

c# ×1

c#-4.0 ×1

programming-languages ×1