没有合适的方法来覆盖c#,尽管有一个?

CMO*_*MOS 2 c# overriding interface

我试图在这里找到一个关于这个问题的解决方案,我也觉得我的问题非常小,但我无法弄清楚出了什么问题.它告诉我Rectangle.draw():找不到合适的方法来覆盖.

    public interface shape 
    {
        void draw();
    }

    //concrete classes that implemenet interfaces
    public class Rectangle : shape 
    {
        public override void draw()
        {
            Console.WriteLine(this.GetType().Name + "'s inside function (generate stuff here) ");
        }
    }
Run Code Online (Sandbox Code Playgroud)

Pet*_*iho 7

错误是正确的.如果方法存在于继承的基类中,则只能覆盖该方法.你的Rectangle类没有继承任何东西; 它只实现了界面"形状".

删除"覆盖"关键字,一切都会好的.