我已经看到用于实现INotifyPropertyChanged的用于实现INotifyPropertyChanged的模式?
private void NotifyPropertyChanged(string propertyName)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(propertyName));
}
}
public event PropertyChangedEventHandler PropertyChanged;
有人可以给我的VAR处理程序的必要性检查它的空与直接检查的PropertyChanged之前=的PropertyChanged分配解释== NULL以下模式直?
感谢
可能的重复[为什么C#要求你在每次触发事件时都写一个空检查?](http://stackoverflow.com/questions/3102918/why-does-c-require-you-to-write-a-null-check-every-time-you-fire-an-event) – decyclone 2010-12-16 14:48:00
@decyclone ,这不是一个骗局...... OP不问你为什么必须检查处理程序是否为空,但为什么你需要使用处理程序的本地副本。 – 2010-12-16 14:55:19
VB.NET是否需要这种模式?或者RaiseEvent为你处理? – MCattle 2014-02-13 19:06:47