Introduction: C# Collections

In this post, we will learn about C# Collections .
In C#, the collection represents group/bunch of objects. With the help of collections, you can perform various operations on objects such as a store, update, delete, sort search and retrieve.

In short, most noteworthy work can be performed by C# collections. We can store objects in the collection or array. The collection has an advantage over an array. The array has size limit but objects stored in the collection can grow or shrink therefore it is dynamic.

In my previous posts I have explained various topics like Get site visitor count in
Convert generic list to datatable in Asp.Net C#.Net, Abstract Class in C# with Example,
Routing in Asp.Net MVC with Example
,Use of Global.asax in

Types of Collections in C#:

There are 3 ways to work with collections. The three namespaces are listed below:

  • System.Collections.Generic
  • System.Collections
  • System.Collections.Concurrent

1. System.Collections.Generic classes:

2. System.Collections classes

  • ArrayList
  • Stack
  • Queue
  • Hashtable

3. System.Collections.Concurrent classes

The System.Collections.Concurrent namespace provides set of classes for thread-safe operations. Now multiple threads will not cause problem for accessing the collection items.
This namespace has following classes:

  • BlockingCollection
  • ConcurrentBag
  • ConcurrentStack
  • ConcurrentQueue
  • ConcurrentDictionary
  • Partitioner
  • OrderablePartitioner

I hope you got an idea about C# Collections.
I would like to have feedback from my blog readers.
Your valuable feedback, question, or comments about this article are always welcome.

Leave a Reply

Your email address will not be published. Required fields are marked *

Name *
Email *