看完这篇 MSDN 文章后,我现在想知道将集合定义为继承自ObservableCollection
. 这之间是否有任何显着差异:
class MyCollection : ObservableCollection<MyObject> { }
class Class1
{
private MyCollection _newCollection = new MyCollection();
public Class1()
{
_newCollection.Add(new MyObject());
}
}
还有这个:
class Class1
{
private ObservableCollection<MyObject> _newCollection = new ObservableCollection<MyObject>();
public Class1()
{
_newCollection.Add(new MyObject());
}
}
有什么我在这里忽略的吗?