C# 4.0 supports explicit co-variance and contra-variance. You could use the out keyword in the ObservableCollection interface declaration: public interface ObservableCollection { //The ObservableCollection methods } And then the interface will be co-variant. More about it: Covariance and Contravariance (C# and Visual Basic) Covariance and Contravariance FAQ How is Generic Covariance & Contra-variance Implemented in C# 4.0?
3 Not on a class you can't. – Richard Friend Jul 8 at 15:21 You're right. Needs to be declared as an interface.
- Fixed the answer. – Yochai Timmer Jul 8 at 15:24.
Switch the top part to something like this: public partial class erarchicalItem { public INotifyCollectionChanged ContainingCollection { get; private set; } public erarchicalItem Parent { get { return (ContainingCollection! = null)? ((ObservableerarchicalCollection)ContainingCollection).
Owner : null; } } } You have to use the non-generic interface because, as Nicholas, states co-variance is your enemy in this instance.
Note that my answer assumes 3.5 or below. If using 4.0, go with Yochai's answer. – JaCraig Jul 8 at 15:58.
In your example, the ObservableerarchicalCollection is only ever instantiated with T = If that will always be the case, you could try making the collection non-generic and inheriting from ObservableCollection instead. If not, you may be able to change erarchicalItem to also be abstract and generic, (erarchicalItem where T : erarchicalItem) like IComparable and similar interfaces do. You would then have DerivedItem : which would have a ContainingCollection of type Observable Note that this could make mixing item types difficult.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.