Tech moves fast! Stay ahead of the curve with Techopedia!
Join nearly 200,000 subscribers who receive actionable tech insights from Techopedia.
In programming, a collection is a class used to represent a set of similar data type items as a single unit. These unit classes are used for grouping and managing related objects.
A collection has an underlying data structure that is used for efficient data manipulation and storage. Code readability and maintenance improves when collections are used in logical constructs.
Collections are designed to group certain objects with a logical connection. For example, a StudentCollection object may be used to maintain university student details. Details may include the total number of students or offer a student search facility based on attributes, such as name, class or grade.
Collections are used under the following conditions:
The .NET Framework provides a number of collection types, such as an array list, linked list, stack, queue or dictionary. Custom collections may be used when there is an implementation requirement for a special or new data structure. This may be done to host specific types, improve performance or modify by overriding existing collection class functionality. Using custom collections in the application architecture involves additional development resources.
Selecting the right type of collection is based on the usage pattern of a collection. Examples include dictionary collection, queue, stack, sorted dictionary and generics.