D
Daniel Klein
I think I've done my homework and checked around on Google Groups but this
seems to be a situation not yet covered.
Here is the scenario...
There are two classes, Foo and Bar (actually there are more than two
classes involved but two will suffice to explain the problem), and each
class has a Copy() method as follows:
Public Function Copy() As Object Implements ICloneable.Clone
' returns a copy of a Foo object
End Function
Public Function Copy() As Object Implements ICloneable.Clone
' returns a copy of a Bar object
End Function
I have another class that subclasses ArrayList. This class allows the list
to contain Foo and Bar objects.
With me so far? Here comes the kicker...
I then iterate over the ArrayList as follows making a copy of the array
list:
Dim objekt, objcopy As Object
For Each objekt In myArrayListInstance
objcopy = objekt.Copy() ' Each objekt is either a Foo object or a Bar
object
' build another ArrayList with copies of all objects from the original
ArrayList
Next
With 'Option Strict On' this produces a compiler error.
How can I achieve this kind of polymorphism with 'Option Strict On' ?
Thanks for your consideration,
Daniel Klein
Cuyahoga Falls, OH
seems to be a situation not yet covered.
Here is the scenario...
There are two classes, Foo and Bar (actually there are more than two
classes involved but two will suffice to explain the problem), and each
class has a Copy() method as follows:
Public Function Copy() As Object Implements ICloneable.Clone
' returns a copy of a Foo object
End Function
Public Function Copy() As Object Implements ICloneable.Clone
' returns a copy of a Bar object
End Function
I have another class that subclasses ArrayList. This class allows the list
to contain Foo and Bar objects.
With me so far? Here comes the kicker...
I then iterate over the ArrayList as follows making a copy of the array
list:
Dim objekt, objcopy As Object
For Each objekt In myArrayListInstance
objcopy = objekt.Copy() ' Each objekt is either a Foo object or a Bar
object
' build another ArrayList with copies of all objects from the original
ArrayList
Next
With 'Option Strict On' this produces a compiler error.
How can I achieve this kind of polymorphism with 'Option Strict On' ?
Thanks for your consideration,
Daniel Klein
Cuyahoga Falls, OH