6.1. What Are Collections?

We'd like a way to gather up objects or value types as they are created so that they can be managed as a group and operated on collectively, along with referring to them individually when necessary. For example:

  • A Professor object may wish to step through all Student objects registered for a particular Course that the professor is teaching in order to compute their grades.

  • The SRS application as a whole may need to step through all the Course objects in the current schedule of classes to determine which of them don't yet have any students registered for them, possibly to cancel these courses.

We use a special type of object called a collection to group other objects or value types. A collection object can hold/contain ...

Get Beginning C# 2008 Objects: From Concept to Code now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.