Generic Types Question

  • Thread starter Thread starter Angel Mateos
  • Start date Start date
A

Angel Mateos

I have this structure:

Class ElemBase

Class Elem1 : Inherits ElemBase

Class ColecBase(Of GenElem As {ElemBase, New}) : Inherits
System.ComponentModel.BindingList(Of GenElem)

Class Colec1 : Inherits ColecBase(Of Elem1)

Class Class1

Public E As ElemBase

Public C As ColecBase(Of ElemBase)

End Class

Class Class2

Dim ColH As Colec1

Dim Cl1 As Class1

Sub proc()

Cl1.C = ColH

End Sub

End Class

I get an error in sub proc because Colect1 can't be converted to
ColecBase(of ElemBase)

there is a way to do this?



Thanks
 
"Angel Mateos" <amateos@nospam.es> a écrit dans le message de Or%23qg7TOHHA.1248@TK2MSFTNGP02.phx.gbl...

| I get an error in sub proc because Colect1 can't be converted to
| ColecBase(of ElemBase)
|
| there is a way to do this?

No. Google for "generic covariance"

Joanna
 
Back
Top