我是 c# 的新手,我在实现接口(interface)方面有点吃力,如果有人能帮助我解决这个问题并提供解释,我将不胜感激。谢谢
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();
}
}
最佳答案
您需要实现接口(interface)中的确切功能(使用相同数量的输入参数)..
所以在您的情况下,将您的界面更改为:
interface Figura
{
String Perimetar(int a, int b, int c)
String Plostina(int a, int b, int c)
}
或者将您的实现更改为不带参数的函数。
关于c# - 错误 : Does not implement interface member,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23170561/