Relationships Among Objects
Objects can be related to each other in several ways. The principal kinds of relationship are hierarchical and containment.
When classes are derived from more fundamental classes, they are said to have a hierarchical relationship. Class hierarchies are useful when describing items that are a subtype of a more general class. For example, in thenamespace, the and classes both derive from the class. Derived classes inherit members from the class they are based on, allowing you to add complexity as you progress in a class hierarchy.
Another way that objects can be related is a containment relationship. Container objects logically encapsulate other objects. For example, theobject logically contains a object, which it returns through its property. Note that the container object does not physically contain any other object.
One particular type of object containment is represented by collections. Collections are groups of similar objects that can be enumerated. Visual Basic supports a specific syntax in thethat allows you to iterate through the items of a collection. Additionally, collections often allow you to use an to retrieve elements by their index or by associating them with a unique string. Collections can be easier to use than arrays because they allow you to add or remove items without using indexes. Because of their ease of use, collections are often used to store forms and controls.