样品代码:
public event PropertyChangedEventHandler PropertyChanged; private void OnPropertyChanged(String propertyName) { PropertyChangedEventHandler handler = PropertyChanged; if (handler != null) { handler(this,new PropertyChangedEventArgs(propertyName)); } }
VS:
public event PropertyChangedEventHandler PropertyChanged; private void OnPropertyChanged(String propertyName) { if (PropertyChanged!= null) { PropertyChanged(this,new PropertyChangedEventArgs(propertyName)); } }
为什么我总是看到人们创建将PropertyChanged分配给“处理程序”而不是仅仅使用它?