You need to use virtual
keyword
abstract class Base
{
// use virtual keyword
public virtual int x
{
get { throw new NotImplementedException(); }
}
}
or define an abstract property:
abstract class Base
{
// use abstract keyword
public abstract int x { get; }
}
and use override
keyword when in the child:
abstract class Derived : Base
{
// use override keyword
public override int x { get { ... } }
}
If you're NOT going to override, you can use new
keyword on the method to hide the parent's definition.
abstract class Derived : Base
{
// use new keyword
public new int x { get { ... } }
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…