Hopefully someone can set me on the right path here, or tell me it can't be done and stop me going round in circles!
I'm trying to pass a Generic.List to a function - it could be a list of any entity that implements a specified interface.
Say I've got
If I use single objects, like in the code below, it's Ok
but what I want to do is pass a list of entities, like
it tells me
Value of type 'System.Collections.Generic.List(Of TestInterfaces.CEntity1)' cannot be converted to 'System.Collections.Generic.List(Of TestInterfaces.ITest)'.
Now, is this just not workable or am I missing something?
If anyone could nudge me in the right direction, it really would be much appreciated (I'm using the VB .Net Beta2 - .Net 2.0, btw)
Cheers,
Monkey36.
I'm trying to pass a Generic.List to a function - it could be a list of any entity that implements a specified interface.
Say I've got
Code:
Public Interface ITest
ReadOnly Property Size() As Single
End Interface
Public Class CEntity1
Implements ITest
Public ReadOnly Property Size() As Single Implements ITest.Size
Get
Return 1
End Get
End Property
End Class
If I use single objects, like in the code below, it's Ok
Code:
Private Sub Test
Dim entity As New CEntity1
ReceiveITest(entity)
End Sub
Private Sub ReceiveITest(entity As ITest)
End Sub
but what I want to do is pass a list of entities, like
Code:
Private Sub Test
Dim entities As New Generic.List(Of CEntity1)
ReceiveITestList(entities)
End Sub
Private Sub ReceiveITestList(entities As Generic.List(Of ITest)
End Sub
it tells me
Value of type 'System.Collections.Generic.List(Of TestInterfaces.CEntity1)' cannot be converted to 'System.Collections.Generic.List(Of TestInterfaces.ITest)'.
Now, is this just not workable or am I missing something?
If anyone could nudge me in the right direction, it really would be much appreciated (I'm using the VB .Net Beta2 - .Net 2.0, btw)
Cheers,
Monkey36.