我认为两者是相同的,但我发现它们只在一个文件中使用,例如下面的代码。这里是 raisepropertychanged 的代码。
public decimal Amount
{
get
{
return _amount;
}
set
{
_amount = value;
RaisePropertyChanged("Amount");
}
}
这里是 PropertyChanged 的代码:
public event PropertyChangedEventHandler PropertyChanged;
private void RaisePropertyChanged(string propertyName)
{
// take a copy to prevent thread issues
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(propertyName));
}
}
请解释它们之间的区别: