Link to home
Start Free TrialLog in
Avatar of caibeier
caibeier

asked on

What does Strong Typed mean for VB.NET CollectionBase

Hi experts, I'm just wondering what does  Strong Typed mean for .NET CollectionBase Class

is it possible to hold both base and its derived class in a collectionbase?

For example, I have a base class and a class derived from the base class

public class BaseClass
    protected member1 as string

    public overridable sub mySub()
       'do something for base class
    End Sub
End Class

Public Class DerivedClass
   Inherits BaseClass
   
   Public override Sub mySub()
       'Do somthing and override mySub in base class
   End Sub
End Class

Now I define a baseclass collection

Public Class BaseClassCollection
   Inherits CollectionBase
   .....
End Class


and suppose I define an instance of BaseClassCollection

Dim myCollection as BaseClassCollection

and I put a few BaseClass objects and DerivedClass into myCollection. and suppose myCollection.Item(1) is of type DerivedClass

My question is, if I call the member function myCollection.Item(1).mySub(), is baseClass.mySub() invoked or DerivedClass.mySub() invoked?

Thanks for your help


ASKER CERTIFIED SOLUTION
Avatar of jrscherer
jrscherer
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial