I have an abstract class with an abstract property for which both Get and Set are set. I know that I will always want to get this property from derived classes, but there are some cases where it makes no sense to set this property in certain types of derived classes.
I can't just omit the Set installation element in a derived class (see code example below). I could override the set of accessors in derived classes so that I don’t do anything with the values passed by the user. But is there another way that a property in a particular derived class is actually read-only? Ultimately, I show these properties in the property grid, and I do not want the user to enter values in a field that will not do anything. Maybe I just pass the property as read only in certain derived classes?
Also, I really would not want to mess with any type of type descriptor to correctly display properties in the property grid, for example, override ICustomTypeDescriptor.
public abstract class MyClass
{
public abstract string MyProperty
{
get;
set;
}
}
public abstract class MyDerivedClass
{
public override string MyProperty
{
get;
}
}