更新:2007 年 11 月
错误消息
无法从这些实参推断扩展方法“<methodname>”(在“<typename>”中定义)中类型形参的数据类型。此错误可以通过显式指定数据类型来更正。
在计算对泛型扩展方法的调用时,已经尝试使用类型推断功能来确定类型形参的数据类型。但是,编译器无法找到此方法中的类型形参的数据类型,因此它报告此错误。
说明: |
|---|
当无法指定实参时(例如,对于查询表达式中的查询运算符),显示的错误消息不包括第二个句子。 |
下面的代码演示此错误。
Module Module1
Sub Main()
Dim classInstance As ClassExample
'' Not valid.
'classInstance.GenericExtensionMethod("Hello", "World")
End Sub
<System.Runtime.CompilerServices.Extension()> _
Sub GenericExtensionMethod(Of T)(ByVal classEx As ClassExample, _
ByVal x As String, ByVal y As _
InterfaceExample(Of T))
End Sub
End Module
Interface InterfaceExample(Of T)
End Interface
Class ClassExample
End Class
**错误 ID:**BC36649 和 BC36646
更正此错误
- 您或许能够指定类型形参的数据类型,而无需依赖类型推断。
说明: