---
title: "Explain the difference between generic collections and non-generic collections in C#"  
description: "Explain the difference between generic collections and non-generic collections in C#"  
author: "Steilla Mitchel"  
published: 2023-11-03  
updated: 2023-11-20  
canonical: https://www.mindstick.com/forum/160380/explain-the-difference-between-generic-collections-and-non-generic-collections-in-c-sharp  
category: "c#"  
tags: ["c#", "collection", "generics"]  
reading_time: 2 minutes  

---

# Explain the difference between generic collections and non-generic collections in C#

[Explain](https://www.mindstick.com/forum/157854/what-is-system-debugging-explain-some-system-debugging-tools-used-in-modern-computer-systems) the [difference between generic](https://www.mindstick.com/forum/160391/explain-the-difference-between-generic-classes-and-non-generic-classes-in-c-sharp) collections and non-[generic collections](https://www.mindstick.com/forum/160398/explain-the-benefits-of-using-generic-collections-over-non-generic-collections-in-c-sharp) in C#

## Replies

### Reply by Aryan Kumar

Certainly! In C#, the main [difference](https://www.mindstick.com/articles/157114/good-news-or-bad-news-and-the-difference-is) between generic [collections](https://www.mindstick.com/articles/12458/what-are-collections-in-c-sharp) and non-generic collections lies in the type of elements they can hold.

## Generic Collections:

- **Definition:** Generic collections are collections that can hold elements of a specific type, known at compile-time.
- **Advantage:** They provide type safety, ensuring that you can only add elements of the specified type to the collection.
- **Example:** In C#, **List<T>**, **Dictionary<TKey, TValue>**, and **Queue<T>** are examples of generic collections. Here, **T** represents the type of elements the collection can hold.

## Non-Generic Collections:

- **Definition:** Non-generic collections are collections that can hold elements of type **object**, allowing them to store any type of object.
- **Drawback:** They lack type safety, as you can add any object to the collection without compile-time type checking.
- **Example:** In C#, **ArrayList**, **Hashtable**, and **Queue** (non-generic version) are examples of non-generic collections.

In summary, the key distinction is that generic collections provide type safety by specifying the type of elements they can hold at compile-time, while non-generic collections work with objects of type **object**, allowing for greater flexibility but sacrificing compile-time type checking. It's generally recommended to use generic collections when possible for type safety and improved performance.


---

Original Source: https://www.mindstick.com/forum/160380/explain-the-difference-between-generic-collections-and-non-generic-collections-in-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
