Skip to content

Latest commit

 

History

History
63 lines (46 loc) · 2.5 KB

bc36660-bc36657.md

File metadata and controls

63 lines (46 loc) · 2.5 KB
description title ms.date f1_keywords helpviewer_keywords ms.assetid
Learn more about: Data type(s) of the type parameter(s) in method '<methodname>' cannot be inferred from these arguments because they do not convert to the same type
Data type(s) of the type parameter(s) in method '<methodname>' cannot be inferred from these arguments because they do not convert to the same type
07/20/2015
vbc36660
bc36660
vbc36657
bc36657
BC36660
BC36657
e80c5afd-e16d-4f03-bdf1-c79c4286114b

Data type(s) of the type parameter(s) in method '<methodname>' cannot be inferred from these arguments because they do not convert to the same type

Data type(s) of the type parameter(s) in method '<methodname>' cannot be inferred from these arguments because they do not convert to the same type. 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. The compiler could not find a data type that meets the constraints of all the arguments. Therefore, it reported this 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.

The following code demonstrates the error.

Option Strict Off
Module Module1
    Sub Main()

        '' Not valid. Integer and Date do not convert to the same type.
        'targetMethod(19, #3/4/2007#)

    End Sub

    Sub targetMethod(Of T)(ByVal p1 As T, ByVal p2 As T)
    End Sub

End Module

Error ID: BC36660 and BC36657

To correct this error

  • You may be able to convert one or more arguments explicitly to a compatible type, as shown in the following code:

    targetMethod(19, #3/4/2007#.ToOADate)
  • You may be able to specify a data type for the type parameter or parameters to which the arguments convert, as shown in the following code:

    targetMethod(Of String)(19, #3/4/2007#)

See also