D
DraguVaso
Hi,
I'm getting in trouble with the Generic.List(Of T).
When declaring a Shadoiws of Mybase.Add, I want to do some custom actions
with the item, and cast it to another class. The problem is that I get the
whole time this error: "value of type 'T' cannot be converted to
'clsBaseClass'".
I get it with both CType and Directcast:
Public Class TestList(Of T)
Inherits List(Of T)
Public Shadows Sub Add(ByVal item As T)
Dim cls As New clsBaseClass
cls = CType(item, clsBaseClass) '-> gives the error
cls = DirectCast(item, clsBaseClass) '-> gives the error
End Sub
End Class
Any help our hints would be really appreciated!
Thanks a lot in advance,
Pieter
I'm getting in trouble with the Generic.List(Of T).
When declaring a Shadoiws of Mybase.Add, I want to do some custom actions
with the item, and cast it to another class. The problem is that I get the
whole time this error: "value of type 'T' cannot be converted to
'clsBaseClass'".
I get it with both CType and Directcast:
Public Class TestList(Of T)
Inherits List(Of T)
Public Shadows Sub Add(ByVal item As T)
Dim cls As New clsBaseClass
cls = CType(item, clsBaseClass) '-> gives the error
cls = DirectCast(item, clsBaseClass) '-> gives the error
End Sub
End Class
Any help our hints would be really appreciated!
Thanks a lot in advance,
Pieter