I am having some trouble with an idea that at its simplest seems like it should work.
I am trying to overload a Property of Type BindingList<T>
in a subclass with a BindingList
of <subclasss T>
. There are ways I can get around this but it seems the 'nicest' way would be without any direct casting. I have tried a bunch of options and have some solutions but I am not particularly happy with any of them.
Is there a best approach to this? A simple code example might be the best descriptor
In this example below, I want to derive a fruitbowl to contain only apples but use the same property name to access this BindingList<>
of Apples (in the case of the subclass; generic fruit in the case of the Super class).
--------Example-------
class Fruit{}
class Apple: Fruit {}
class FruitBowl
{
protected BindingList<Fruit> m_aFruits;
public BindingList<Fruit> Fruits
{
get {return m_aFruits;}
}
}
class AppleBowl : FruitBowl
{
public BindingList<Apple> Fruits
{
get {return m_aFruits;}
}
}