我有一个接口:如何从接口覆盖方法?
interface ISqlite
{
DataTable select(SQLiteDatabase db);
}
和实现它:
public DataTable select(ISqlite s) {
return s.select(driver);
}
正如你所看到的方法select
与DataTable
型回报描述。
如何覆盖此方法,以便它不返回DataTable
,而是返回数组或任何其他类型?
我指的是以下几点:
public Array select(ISqlite s) {
return s.select(driver);
}
你不能那样做。 https://en.wikipedia.org/wiki/Liskov_substitution_principle – SLaks
对于要实现接口的类,它必须完全匹配方法的签名。所以,你需要更新接口和所有实现类。 – juharr
你的意思是我需要编写额外的界面并将它添加到类中? – ITMANAGER