Introduction

C# Collections

C# collection types are designed to store, manage and manipulate similar data more efficiently. Data manipulation includes adding, removing, finding, and inserting data in the collection. Collection types implement the following common functionality:

  • Adding and inserting items to a collection

  • Removing items from a collection

  • Finding, sorting, searching items

  • Replacing items

  • Copy and clone collections and items

  • Capacity and Count properties to find the capacity of the collection and number of items in the collection

Types of C# Collection Classes

In C# collections are divided into 3 classes. They are:

  1. System.Collections.Generic

  2. System.Collections

  3. System.Collections.Concurrent

System.Collections.Generic

The System.Collections.Generic namespace has following classes:

  • List

  • HashSet

  • Stack

  • Queue

  • LinkedList

  • SortedSet

  • Dictionary

  • SortedDictionary

  • SortedList

System.Collections.Generic

These classes are legacy. It is suggested now to use System.Collections.Generic classes. The System.Collections namespace has following classes:

  • ArrayList

  • Stack

  • Queue

  • Hashtable

Collection Interface Hierarchy

Detailed reading

Last updated