我試圖調用一個函數,但我得到的錯誤是「xxxx的最佳重載方法匹配有一些無效參數」。當我在它懸停,我得到的選項「生成方法存根...」調用函數時出現錯誤
導致錯誤的代碼是:
if (oCustomerDAL.VerifyCustomerLoginID(ref oSubscriber)) { }
相關功能是:
public bool VerifyCustomerLoginID(ref IAuthenticate oSystemUser)
我該如何解決錯誤?
我試圖調用一個函數,但我得到的錯誤是「xxxx的最佳重載方法匹配有一些無效參數」。當我在它懸停,我得到的選項「生成方法存根...」調用函數時出現錯誤
導致錯誤的代碼是:
if (oCustomerDAL.VerifyCustomerLoginID(ref oSubscriber)) { }
相關功能是:
public bool VerifyCustomerLoginID(ref IAuthenticate oSystemUser)
我該如何解決錯誤?
的方法使用ref
關鍵字,您還需要提供它調用方法時:
if (oCustomerDAL.VerifyCustomerLoginID(ref oSubscriber)) { }
(OP被遺漏的ref
編輯之前)
編輯。您還應該檢查oSubscriber
是什麼類型。確保它實現了接口IAuthenticate
,因爲這是您嘗試調用的方法所需的接口。
爲此找到其oSubscriber
是一個實例類的定義,並確保它看起來是這樣的(C#)
public class Subscriber : IAuthenticate
{
...
}
if (oCustomerDAL.VerifyCustomerLoginID(ref oSubscriber)) { }
實際上....仍然得到同樣的錯誤消息:-( – DotNetRookie
仍然會收到相同的錯誤消息:-( – DotNetRookie
oSubscriber代表的類是否實現IAuthenticate? – Jamiec
如何確保該類實現IAuthenticate?在OOP中不太好.... – DotNetRookie