【发布时间】:2016-03-05 10:48:45
【问题描述】:
为什么我不能写这样的扩展方法?在课堂上我可以使用 this.PropertyChanged != null。是编译器限制、dotnet 规范限制还是内部代码实现限制?我的开发人员直觉告诉我这应该是可能的;)。
public static class Ext {
public static void OnPropertyChanged(this INotifyPropertyChanged npc, string propertyName) {
if (npc.PropertyChanged != null) {
npc.PropertyChanged(npc, new PropertyChangedEventArgs(propertyName));
}
}
}
错误事件“System.ComponentModel.INotifyPropertyChanged.PropertyChanged”只能出现在+=或-=的左侧
【问题讨论】:
标签: extension-methods inotifypropertychanged