我在ObservableCollection<T>
使用反编译器时环顾四周,看到了一些OnPropertyChanged
我以前从未见过的奇怪代码。
public class ObservableCollection<T> : Collection<T>, INotifyCollectionChanged, INotifyPropertyChanged
{
private const string IndexerName = "Item[]";
protected override void ClearItems()
{
...
base.OnPropertyChanged("Count");
base.OnPropertyChanged("Item[]");
...
}
}
OnPropertyChanged("Item[]")
在编写我自己的代码时,调用有什么用?
它必须做一些不同于标准OnPropertyChanged
调用的事情,因为“Item”不是对象上的属性,并且“ []
”肯定不是“任何”属性名称的一部分。