Is it possible to do something like this?
class A
{
public virtual string prop
{
get
{
return "A";
}
}
}
class B: A
{
private string X;
public override string prop
{
get
{
return X;
}
set
{
X = value;
}
}
}
That is, the base class provides a virtual property with only a GET accessor, but the child class overrides the GET and also provides a SET.
The current example doesn't compile, but perhaps I'm missing something here.
Added: To clarify, no I don't want to redefine with new. I want to add a new accessor. I know it wasn't in the base class, so it cannot be overriden. OK, let me try to explain how it would look without the syntactic sugar:
class A
{
public virtual string get_prop()
{
return "A";
}
}
class B: A
{
private string X;
public override string get_prop()
{
return X;
}
public virtual string set_prop()
{
X = value;
}
}