假设我们有以下模型:
public class Bar<T>:List<T>
{
public delegate void CollectionChangedDelegate();
public event CollectionChangedDelegate CollectionChanged;
}
public class Foo
{
Bar<object> MyCollection = new Bar<object>();
public Foo()
{
MyCollection.CollectionChanged += new Bar<object>.CollectionChangedDelegate(MyCollection_CollectionChanged);
}
public void MyCollection_CollectionChanged()
{
//Do Something
}
~Foo() //Would this work ?
{
MyCollection.CollectionChanged -= MyCollection_CollectionChanged;
}
}
Foo
在这种情况下可以调用Class 的析构函数吗?