La firma del metodo '<methodname>' non è compatibile con il delegato <'delegatename'>

Questo errore si verifica quando è necessario eseguire una conversione tra un metodo e un delegato che non è possibile. La causa dell'errore può essere la conversione tra parametri o, quando il metodo e il delegato sono funzioni, la conversione nei valori restituiti.

Il codice seguente illustra le conversioni non riuscite. Il delegato è FunDel.

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

Ognuna delle funzioni seguenti differisce da FunDel in modo tale da generare questo errore.

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  

Ognuna delle istruzioni di assegnazione seguenti genera l'errore.

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 errore: BC31143

Per correggere l'errore

  • Esaminare i parametri corrispondenti e, se sono presenti, i tipi restituiti per determinare la coppia che non è compatibile.

Vedi anche