I have the following classes. For each of the control classes, I'd like to expose the data member via a property.
public class BasicData {}
public class AdvancedData : BasicData { }
public class BasicControl
{
private BasicData data;
public BasicData DataHide;
public virtual BasicData DataOverride;
}
public class AdvancedControl: BasicControl
{
private AdvancedData data;
public new AdvancedData DataHide; //Hide
public override BasicData DataOverride; //Override
}
If I make the property virtual, then my AdvancedControl
class has to expose the data as BasicData
and not AdvancedData
(which I'd prefer).
I can instead hide the base class's property but I've read that hiding should be avoided where possible.
I want to have just one data property exposed for each Control class and I want this property to have the same name in each class i.e. Data
. For BasicControl
this should be BasicData
. For AdvancedControl
this should be AdvancedData
.
What's the best way of designing my classes to achieve this?