Collections in .NET

Posted on


One of the problems with array was its fixed size. To overcome this problem a way is collection. Collections provide a flexible way to work with groups of objects. These objects can grow and shrink dynamically as per the needs of the applications. To retrieve the values faster some collections provide the key that can be assigned to the objects which make the retrieval of the content fast.

As collection is a class, it must declare a new collection before adding elements to that collection.

Various Collection Classes and Their Usage

The following are the commonly used classes of the System.Collection namespace.

Class Description and Usage

  • ArrayList :- It represents the ordered collection of an object that can be indexed individually. It is an alternative to an array. Items can be added and removed from a list at a specified position using an index and the array get resized automatically. It also allows dynamic memory allocation, adding, searching and sorting items in the list.
  • Hashtable :- It accesses the elements in the collection with the help of a key. It is used when value is to be accessed by using key, and value is identified based on key value. Each item in the hash table has a key/value pair. The key is used to access the items in the collection.
  • SortedList :-  It uses a key and an index to access the items in a list. It is a combination of an array and a hash table. It contains a list of items that can be accessed using a key or an index. When the value is accesses using an index, it is an ArrayList, and when accesses using a key , it is a Hashtable. The collection of items is always sorted by the key value.
  • Stack :- It represents a LIFO (Last-in, first out) collection of object. It is used when last-in, first-out access of items is required. When item is added in the list, it is called pushing and when it is removed, is called popping the item.
  • Queue :- It represents a FIFO (First-in, first out) collection of object. It is used when first- in, first-out access of items is required. When item is added in the list, it is called enqueue and when it is removed is called dequeue.
  • BitArray :- It represents an array of the binary representation using the values 1 and 0. It is used when bits are to be stored but do not know the number of bits in advance. Items can be accessed from the BitArray collection by using an integer index, which starts from zero.


For more details and queries please feel free to email, visit or call us. Wishing you the very best for all your future endeavors.
Helpline: 9814666333, 8699444666

Please fill the form and we shall contact you soon.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s