Tue , May 02 2023
C# includes specialized classes that store series of values or objects, called collections.
The limitation of these collections is that they are strongly typed and have a fixed size.
There are two types of collections available in C#: non-generic collections and generic collections. Both examples above fall under non-generic collections.
System.Collections namespace contains non-generic collection types, and System.Collections.Generic namespace includes generic collection types.
To overcome type and size limitations, .NET introduced generic collections.
.Net Collection | Generic Collection |
---|---|
Array list | List (Generic) |
Hash table | Dictionary |
Stack | Stack (Generic) |
Queue | Queue (Generic) |
Generic Collection | Description |
---|---|
List | Contains elements of the specified type and grows automatically. |
Dictionary | Contains key-value pairs. |
SortedList | Stores key-value pairs and automatically sorts them. |
Queue | Stores values in FIFO (First In First Out) style. |
Stack | Stores values in LIFO (Last In First Out) style. |
HashSet | Contains non-duplicate elements. |
I am an engineer with over 10 years of experience, passionate about using my knowledge and skills to make a difference in the world. By writing on LifeDB, I aim to share my thoughts, ideas, and insights to inspire positive change and contribute to society. I believe that even small ideas can create big impacts, and I am committed to giving back to the community in every way I can.
Leave a Reply