2012-06-28 104 views
0

我試圖調用一個函數,但我得到的錯誤是「xxxx的最佳重載方法匹配有一些無效參數」。當我在它懸停,我得到的選項「生成方法存根...」調用函數時出現錯誤

導致錯誤的代碼是:

if (oCustomerDAL.VerifyCustomerLoginID(ref oSubscriber)) { } 

相關功能是:

public bool VerifyCustomerLoginID(ref IAuthenticate oSystemUser) 

我該如何解決錯誤?

回答

2

的方法使用ref關鍵字,您還需要提供它調用方法時:

if (oCustomerDAL.VerifyCustomerLoginID(ref oSubscriber)) { } 

(OP被遺漏的ref編輯之前)


編輯。您還應該檢查oSubscriber是什麼類型。確保它實現了接口IAuthenticate,因爲這是您嘗試調用的方法所需的接口。

爲此找到其oSubscriber是一個實例類的定義,並確保它看起來是這樣的(C#)

public class Subscriber : IAuthenticate 
{ 
    ... 
} 
+0

仍然會收到相同的錯誤消息:-( – DotNetRookie

+0

oSubscriber代表的類是否實現IAuthenticate? – Jamiec

+0

如何確保該類實現IAuthenticate?在OOP中不太好.... – DotNetRookie

4
if (oCustomerDAL.VerifyCustomerLoginID(ref oSubscriber)) { } 
+0

實際上....仍然得到同樣的錯誤消息:-( – DotNetRookie

相關問題