Рассмотрим следующий интерфейс:
Код: Выделить всё
public interface ICustomNotifyPropertyChanged:
INotifyPropertyChanged
{
public void OnPropertyChanged (string propertyName);
// Compiler Error: [CS0079].
//public void OnPropertyChanged (string propertyName)
// => this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
protected bool SetField (ref T field, T value, [CallerMemberName] string propertyName = "")
{
if (EqualityComparer.Default.Equals(field, value)) { return (false); }
field = value;
this.OnPropertyChanged(propertyName);
return (true);
}
}
Код: Выделить всё
CS0079: The event 'ICustomNotifyPropertyChanged.PropertyChanged' can only appear on the left hand side of += or -=.
Подробнее здесь: https://stackoverflow.com/questions/791 ... -causing-a
Мобильная версия