这是我想做的事情:
顶部是一个界面:
interface IHasPosition
{
Position Position
{
get;
}
}
接下来,我们有一个抽象类:
abstract class Person : IHasPosition
{
public abstract Position Position
{
get;
}
}
最后,我扩展了 Person:
class Instructor : Person
{
public override Position Position
{
get { return new Position(1, 1); }
}
}
这编译得很好。但是,我似乎无法明确定义属性位置。像这样的东西:
class Instructor : Person
{
public override Position IHasPosition.Position
{
get { return new Position(1, 1); }
}
}
这无法编译:
Error 1 'ConsoleApplication3.Instructor.IHasPosition.Position': virtual or abstract members cannot be private
Error 3 The modifier 'override' is not valid for this item
Error 2 The modifier 'public' is not valid for this item