错误:未实现接口成员

时间:2014-04-19 13:19:49

标签: c# interface

我是c#的新手,我在实施界面方面有点挣扎,如果有人帮我解决这个问题,我将非常感激。谢谢

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace interfejsi
 interface Figura
{
  String Plostina ();
  String Perimeter ();
}
}
 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 namespace interfejsi
{
 class Kvadar : Figura
{
    int a,b,c;
    public  String Perimetar(int a, int b, int c)
    {
        return (a + b + c).ToString();
    }
    public String Plostina(int a, int b, int c)
    {
        return (a * b * c).ToString();
    }
}

}

2 个答案:

答案 0 :(得分:6)

您需要实现位于界面中的确切函数(具有相同数量的输入参数)。

因此,在您的情况下,将您的界面更改为:

interface Figura
{
   String Perimetar(int a, int b, int c)
   String Plostina(int a, int b, int c)
}

或者将实现更改为没有参数的函数。

答案 1 :(得分:0)

方法定义不匹配。在接口中定义了方法String Plostina (),但该类没有该方法。类中的方法具有不同的签名,在类中它看起来像String Plostina(int a, int b, int c)

要实现接口,Name,返回类型和参数(金额,顺序和类型)必须匹配。