kle*_*neg 2 c# polymorphism inheritance overriding namespaces
我在不同的项目中有两个班.
第一个命名GeneralConcept在命名空间,I.am.here并有一个protected virtual名为的方法DoSomething.
第二个是命名的SpecificInstanceOfConcept,位于命名空间I.am.in.a.different.place并继承自GeneralConcept.
我试图覆盖该方法.具有相同的名称,相同的输入,相同的类型,并从实现该方法的类继承.但是,
我一直在说错误
没有合适的方法来覆盖
它的设置方式如下所示,
namespace I.am.here
{
public class GeneralConcept
{
//stuff
protected virtual MyType DoSomething(Inputs input)
{
//more stuff
}
}
}
namespace I.am.in.a.different.place
{
public class SpecificInstanceOfConcept : I.am.here.GeneralConcept
{
//yet more stuff
protected override MyType DoSomething(Inputs input)
{
//even more stuff
}
}
}
Run Code Online (Sandbox Code Playgroud)
谢谢您的帮助.
覆盖命名空间应该不是问题.该错误表示以下之一:
I.am.here.GeneralConcept.DoSomething没有标记为virtual,abstract,或overrideI.am.here.GeneralConcept.DoSomething不是public或protectedI.am.here.GeneralConcept.DoSomething您的覆盖不同.