Search

Tuesday, February 5, 2019

C# Collections Tutorial with Examples

Posted By Manisha Gupta 
In our previous tutorial, we have learned about how we can use arrays in C#. Let's have a quick overview of it, Arrays in programming are used to group a set of related objects. So one could create an array or a set of Integers, which could be accessed via one variable name.

What is Collections in C#?

Collections are similar to Arrays, it provides a more flexible way of working with a group of objects.
In arrays, you would have noticed that you need to define the number of elements in an array beforehand. This had to be done when the array was declared.
But in a collection, you don't need to define the size of the collection beforehand. You can add elements or even remove elements from the collection at any point of time. This chapter will focus on how we can work with the different collections available in C#.
CollectionDescription
ArrayListThe ArrayList collection is similar to the Arrays data type in C#. The biggest difference is the dynamic nature of the array list collection.
StackThe stack is a special case collection which represents a last in first out (LIFO) concept
QueuesThe Queue is a special case collection which represents a first in first out concept
HashtableA hash table is a special collection that is used to store key-value items
SortedListThe SortedList is a collection which stores key-value pairs in the ascending order of key by default.
BitArrayA bit array is an array of data structure which stores bits

Follow on Facebook

ManishaTech . 2017 Copyright. All rights reserved. Designed by Manisha Gupta | Manisha Gupta