方法 '<methodname>' 沒有與委派 <'delegatename'> 相容的簽章
更新:2007 年 11 月
當方法和委派之間需要轉換但不可能進行時,就會發生此錯誤。錯誤的原因可能是參數之間的轉換,或當方法和委派是函式時,則可能是傳回值中的轉換。
下列程式碼示範了失敗的轉換。委派為 FunDel。
Delegate Function FunDel(ByVal i As Integer, ByVal d As Double) As Integer
下列每個函式都不同於 FunDel,因此會導致此錯誤。
Function ExampleMethod1(ByVal m As Integer, ByVal aDate As Date) As Integer
End Function
Function ExampleMethod2(ByVal m As Integer, ByVal aDouble As Double) As Date
End Function
下列每個指派陳述式都會導致錯誤。
Sub Main()
' The second parameters of FunDel and ExampleMethod1, Double and Date,
' are not compatible.
'Dim d1 As FunDel = AddressOf ExampleMethod1
' The return types of FunDel and ExampleMethod2, Integer and Date,
' are not compatible.
'Dim d2 As FunDel = AddressOf ExampleMethod2
End Sub
錯誤 ID:BC31143
若要更正這個錯誤
- 檢查對應參數,如果有對應參數存在,請傳回型別,判斷哪一對參數不相容。