Total Page Preview:   000000025062

What is Collections in C#(sharp) ?

C#(sharp) Collections are data structures that holds data in different ways for flexible operations. C# Collection classes are defined as part of the System.Collections or System.Collections.Generic namespace

Type of Collection:

1. System.Collections.Generic classes

2. System.Collections.Concurrent classes

3. System.Collections classes

 

1: System.Collections.Generic Classes:

We can create a generic collection by using one of the classes in the System.Collections.Generic namespace. A generic collection is useful when every item in the collection has the same data type.A generic collection enforces strong typing by allowing only the desired data type to be added.

Type of Generic Class

 1. Dictionary<TKey, TValue> :- Represents a collection of key/value pairs that are organized based on the key.

 2. List<T>:- Represents a list of objects that can be accessed by index. Provides methods to search, sort, and modify lists.

 3. Queue<T> : - Represents a first in, first out (FIFO) collection of objects.

 4. SortedList<TKey, TValue> :- Represents a collection of key/value pairs that are sorted by key based on the associated IComparer<T> implementation.

 5. Stack<T> : - Represents a last in, first out (LIFO) collection of objects.

 

2: System.Collections.Concurrent Classes :

Concurrent collections in .NET Framework 4.0 allow the developers to create type safe as well as thread safe collections. These collection classes form an essential part of the parallel programming feature and are available under the namespace System.Collections.Concurrent. Below are the different types of concurrent collections

Type of Concurrent Class

1. ConcurrentDictionary< Key , Value>: Thread safe dictionary in key value pairs
2. ConcurrentQueue<T>: Thread safe FIFO data structure
3. ConcurrentStack<T>: Thread safe LIFO data structure
4. ConcurrentBag<T>: Thread safe implementation of an unordered collection
5. BlockingCollection<T>: Provides a Classical Producer Consumer pattern
 
 
3: System.Collections classes :
The classes in the System.Collections namespace do not store elements as specifically typed objects, but as objects of type Object.
 
Type of Collections Class
1. ArrayList : Represents an array of objects whose size is dynamically increased as required.
2. Hashtable: Represents a collection of key/value pairs that are organized based on the hash code of the key.
3. Queue : Represents a first in, first out (FIFO) collection of objects.
4. Stack : Represents a last in, first out (LIFO) collection of objects.
 
Collection in C sharp
Thanks!

Thank You

About Author

Brijesh Kumar

Database Developer

I have more then 6 years Experience in Microsoft Technologies - SQL Server Database, ETL Azure Cloud - Azure SQL Database, CosmosDB, Azure Data Factory, PowerBI, Web Job, Azure Function, Azure Storage, Web Apps, Powershall and Database Migration On-Premise to Azure Cloud.
LinkedIn : https://www.linkedin.com



Comments

Hampden
05-Feb-2017
Today, I went to the beach front with my kids. I found a sea shell and gave it to my 4 year old daughter and said "You can hear the ocean if you put this to your ear." She put the shell to her ear and screamed. There was a hermit crab inside and it pinched her ear. She never wants to go back! LoL I know this is entirely off topic but I had to tell someone!
Hogue
20-Sep-2018
Hey there just wanted to give you a quick heads up and let you know a few of the images aren't loading properly. I'm not sure why but I think its a linking issue. I've tried it in two different web browsers and both show the same outcome.
Spear
07-Oct-2018
Hi there to every body, it's my first visit of this weblog; this weblog contains remarkable and actually excellent information for visitors.
Hackler
17-Feb-2017
It's actually very complicated in this active life to listen news on Television, thus I just use web for that purpose, and get the most recent information.
Martine
22-Nov-2019
I every time used to read piece of writing in news papers but now as I am a user of web so from now I am using net for articles, thanks to web.
Dubois
12-Nov-2019
you are in point of fact a good webmaster. The website loading velocity is incredible. It seems that you are doing any unique trick. In addition, The contents are masterwork. you've done a wonderful process in this subject!
Fewings
16-Nov-2019
Hey there! I know this is sort of off-topic but I needed to ask. Does managing a well-established blog such as yours take a massive amount work? I am completely new to running a blog but I do write in my diary every day. I'd like to start a blog so I can easily share my own experience and thoughts online. Please let me know if you have any recommendations or tips for brand new aspiring bloggers. Thankyou!
Asmus
21-Nov-2019
Very great post. I just stumbled upon your weblog and wanted to mention that I've really loved browsing your blog posts. After all I will be subscribing on your feed and I am hoping you write once more soon!
Wallwork
21-Nov-2019
Just wish to say your article is as astounding. The clarity in your post is just cool and i can assume you're an expert on this subject. Well with your permission allow me to grab your RSS feed to keep updated with forthcoming post. Thanks a million and please continue the gratifying work.
Joshua
16-Nov-2019
Good day I am so delighted I found your weblog, I really found you by accident, while I was looking on Bing for something else, Nonetheless I am here now and would just like to say cheers for a tremendous post and a all round interesting blog (I also love the theme/design), I don't have time to go through it all at the moment but I have bookmarked it and also added in your RSS feeds, so when I have time I will be back to read much more, Please do keep up the fantastic job.
Snowball
21-Nov-2019
wonderful issues altogether, you simply received a emblem new reader. What would you recommend about your publish that you made some days in the past? Any sure?
Kyte
15-Sep-2020
Greetings! I've been following your weblog for some time now and finally got the bravery to go ahead and give you a shout out from Atascocita Tx! Just wanted to tell you keep up the fantastic work!
Samples
03-May-2021
Thanks for the marvelous posting! I actually enjoyed reading it, you could be a great author.I will make certain to bookmark your blog and definitely will come back in the future. I want to encourage continue your great work, have a nice holiday weekend!
Cortina
21-Jul-2021
Quality articles is the key to interest the users to pay a visit the web page, that's what this site is providing.

                           
                           

                           

                           

Facebook User: