我有如下的界面:與功能範圍C#接口問題
public interface IInterface
{
void Open();
void Open(bool flag);
void Open(bool flag, bool otherFlag);
}
現在實現接口我有以下時:
public class IClass : IInterface
{
void IInterface.Open()
{
Open(false, false);
}
void IInterface.Open(bool flag)
{
Open(flag, false);
}
void IInterface.Open(bool flag, bool otherFlag)
{
//Do some stuff
}
}
現在,我遇到的問題是,內IClass中的前兩個函數體,我不能調用第三個函數。我得到的錯誤:
The name 'Open' does not exist in the current context
好了,所以我明確地實現接口(由於從其他球隊在組織的要求),然後我得到了「開放」上下文問題。 我可以從三個打開的方法中移除顯式的IInterface,然後我可以成功編譯,即使使用其他方法(此處未列出)也可以顯式執行,但我不確定這是什麼意思。
有沒有辦法在明確實現接口方法的同時調用第三種方法?
謝謝!