G
Guest
Hi,
I would expect that inheritance through the parameters of a generic class
would be fine however I get errors as below in the following code.
Public Class Form1
Sub test()
Dim xxx As Foo(Of DerivedBase)
Dim zzz As Foo(Of Base)
zzz = xxx '*** Foo(DerivedBase) cannot be converted to Foo(Base)
zzz = CType(xxx, Foo(Of Base)) '*** Foo(DerivedBase) cannot be
converted to Foo(Base)
Dim aaa As Bar(Of Base)
zzz = aaa
End Sub
End Class
Public Class Foo(Of XXX As Base)
End Class
Public Class DerivedBase
Inherits Base
End Class
Public Class Base
End Class
Any (clean) workarounds?
I would expect that inheritance through the parameters of a generic class
would be fine however I get errors as below in the following code.
Public Class Form1
Sub test()
Dim xxx As Foo(Of DerivedBase)
Dim zzz As Foo(Of Base)
zzz = xxx '*** Foo(DerivedBase) cannot be converted to Foo(Base)
zzz = CType(xxx, Foo(Of Base)) '*** Foo(DerivedBase) cannot be
converted to Foo(Base)
Dim aaa As Bar(Of Base)
zzz = aaa
End Sub
End Class
Public Class Foo(Of XXX As Base)
End Class
Public Class DerivedBase
Inherits Base
End Class
Public Class Base
End Class
Any (clean) workarounds?