Data type(s) of the type parameter(s) in method '<methodname>' cannot be inferred from these arguments
Data type(s) of the type parameter(s) in method '<methodname>' cannot be inferred from these arguments. Specifying the data type(s) explicitly might correct this error.
An attempt has been made to use type inference to determine the data type (or types) of the type parameter (or parameters) when evaluating a call to a generic procedure. However, the compiler is not able to find a data type for the type parameters in this method, and it reports the error.
Note
When specifying arguments is not an option (for example, for query operators in query expressions), the error message appears without the second sentence.
For example, the following code demonstrates the error.
Module Module1
Sub Main()
'' Not valid.
'GenericMethod("Hello", "World")
End Sub
Sub GenericMethod(Of T)(ByVal x As String, ByVal y As _
InterfaceExample(Of T))
End Sub
End Module
Interface InterfaceExample(Of T)
End Interface
Error ID: BC36648 and BC36645
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.
See Also
Concepts
Generic Procedures in Visual Basic