You're right.
I had changed and edited the content of the post.
Foo is not a collection of Bar objects. That is what it should read.
An array of Foo objects, base class, is not a collection of Bar objects, derived class.
Public Sub foobar()
Dim foo() As foo = {New foo(), New foo()} ' this is an array of base class objects.
For Each bar As bar In foo 'invalid cast at runtime,
cannot base to derived class Next
End Sub
Widening and Narrowing Conversions "A
widening conversion changes a value to a data type that can accommodate any possible value of the original data.
A
narrowing conversion changes a value to a data type that might not be able to hold some of the possible values."
A derived class can hold any and every field of any base type.
A base class cannot hold any and every field of any derived type.
That code should not compile.
Rudy =8^D
Mark the best replies as answers. "Fooling computers since 1971."