Generic Types Question

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
 
J

Joanna Carter [TeamB]

"Angel Mateos" <[email protected]> a écrit dans le message de Or%[email protected]...

| 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top