Data type(s) of the type parameter(s) cannot be inferred from these arguments

 

Updated: July 20, 2015

For the latest documentation on Visual Studio 2017 RC, see Visual Studio 2017 RC Documentation.

Data type(s) of the type parameter(s) cannot be inferred from these arguments. Specifying the data type(s) explicitly might correct this error.

This error occurs when overload resolution has failed. It occurs as a subordinate message that states why a particular overload candidate has been eliminated. The error message explains that the compiler cannot use type inference to find data types for the type parameters.

System_CAPS_ICON_note.jpg Note

When specifying arguments is not an option (for example, for query operators in query expressions), the error message appears without the second sentence.

The following code demonstrates the error.

Module Module1  
  
    Sub Main()  
  
        '' Not Valid.  
        'OverloadedGenericMethod("Hello", "World")  
  
    End Sub  
  
    Sub OverloadedGenericMethod(Of T)(ByVal x As String,   
                                      ByVal y As InterfaceExample(Of T))  
    End Sub  
  
    Sub OverloadedGenericMethod(Of T, R)(ByVal x As T,   
                                         ByVal y As InterfaceExample(Of R))  
    End Sub  
  
End Module  
  
Interface InterfaceExample(Of T)  
End Interface  

Error ID: BC36647 and BC36644

To correct this error

  • You may be able to specify a data type for the type parameter or parameters instead of relying on type inference.

Relaxed Delegate Conversion
Generic Procedures in Visual Basic
Type Conversions in Visual Basic

Show: