[英]Error: Does not implement interface member
我是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();
}
}
}
您需要實現位於界面中的確切函數(具有相同數量的輸入參數)。
所以在你的情況下,將你的界面更改為:
interface Figura
{
String Perimetar(int a, int b, int c)
String Plostina(int a, int b, int c)
}
或者將實現更改為沒有參數的函數。
方法定義不匹配。 在接口中定義了Method String Plostina ()
,但該類沒有該方法。 類中的方法具有不同的簽名,在類中它看起來像String Plostina(int a, int b, int c)
。
要實現接口,Name,返回類型和參數(金額,順序和類型)必須匹配。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.