---
title: "What is a collection in C#, and how many types of collection in C#?"  
description: "What is a collection in C#, and how many types of collection in C#?"  
author: "Ethan Karla"  
published: 2021-08-26  
canonical: https://answers.mindstick.com/qa/93932/what-is-a-collection-in-c-sharp-and-how-many-types-of-collection-in-c-sharp  
category: "programming"  
tags: ["c#", "java"]  
reading_time: 2 minutes  

---

# What is a collection in C#, and how many types of collection in C#?

What is a [collection in C#](https://www.mindstick.com/forum/160381/how-to-add-items-to-a-list-collection-in-c-sharp), and how many types of collection in C#?

## Answers

### Answer by Ravi Vishwakarma

The **[collection](https://www.mindstick.com/articles/1718/collections-in-java)** is a very important part of the .NET Framework because it represents a group of objects. Many interfaces and classes have been defined in the .NET Framework, which implements different types of collections. Collections fulfill many types of programming needs, which we generally need a lot. Developing these collections is usually quite a typical task, so these commonly used Data Structure Constructs in the .NET Framework have already been well defined and provided as a library. Arrays, Linked Lists, Stacks, Queues, Dictionary, and Hash Tables are mainly defined as Predefined Collections, as these are the data structures that are needed in almost all .NET applications. **C# Collection Types**

1. Non-Generic (System.Collections)
2. Generic (System.Collections.Generic)
3. Concurrent (System.Collections.Concurrent)

## Non-Generic Collection

In C#, non-generic collection classes are useful to store heterogeneous elements, these are provided by System. Collections namespace. This collection presents some classes ArrayList -> its represent the array, its length is automatically increase Queue -> its is based on FIFO ( first in first out ) Stack -> its is based on LIFO (Last in first out ) Hashtable -> it is based on the key, value pair **Syntax**

```
    Stack stack=new Stack();
```

it is store value in LIFO order but for any datatype value. **Generic Collection** In C#, generic collection can store only the elements with the same data type, and these are provided by System.Collection.Generic namespace. List Stack Queue SortedList<K, V> Dictionary<K, V> **Syntax**

```
    List<T> lst = new List<T>();
```

in this syntax <T>, T represents any datatype

```
    List<int> lst = new List<int>();
```

int the example list is an integer type, in another word this list is always taken integer value no any other datatype value. **Concurrent Collection** If we are using multiple threads to access a collection concurrently, then we need to use the concurrent collection class, \


---

Original Source: https://answers.mindstick.com/qa/93932/what-is-a-collection-in-c-sharp-and-how-many-types-of-collection-in-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
