Metoda "<methodname>" nie ma podpisu zgodnego z delegatem "delegatename <">

Ten błąd występuje, gdy wymagana jest konwersja między metodą a pełnomocnikiem, który nie jest możliwy. Przyczyną błędu może być konwersja między parametrami lub, gdy metoda i delegat są funkcjami, konwersja w zwracanych wartościach.

Poniższy kod ilustruje nieudane konwersje. Pełnomocnik to FunDel.

Delegate Function FunDel(ByVal i As Integer, ByVal d As Double) As Integer  

Poniższe funkcje różnią się od FunDel sposobu, który spowoduje ten błąd.

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  

Każda z poniższych instrukcji przypisania powoduje błąd.

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  

Identyfikator błędu: BC31143

Aby poprawić ten błąd

  • Sprawdź odpowiednie parametry i, jeśli są obecne, zwróć typy, aby określić, która para nie jest zgodna.

Zobacz też