我与 mustInherit 类一起工作
我创造了一些看起来像这样的东西
Sub OnLoad
...
Dim o As Object = BaseX(Of Object).LoadItem
dim gv as Gridview = o.AddGridview(myPanel)
...
end Sub
MustInherit Class BaseX(Of T1)
Public Shared Function LoadItem() As Object
...
'Create Item FirstX or SecondX
'return the new Item
...
End Function
Public Function GetGridview(ByVal container As Panel) As Gridview
'return a gridview
End Function
End Class
Class FirstX Inherits BaseX(of A)
...
End Class
Class SecondX Inherits BaseX(of B)
...
End Class
我在“dim gv as Gridview = o.AddGridview(myPanel)”上出现错误
错误 18 后期绑定分辨率;可能会发生运行时错误。
错误 19 警告被视为错误:后期绑定解决方案;可能会发生运行时错误。
我试试
Dim gv As GridView = DirectCast(o, BaseX(Of Object)).AddGridview(myPanel)
但我遇到了运行时错误
无法将对象类型 FirstX 转换为 BaseX 类型
如果你有路要走?我应该改变什么?