SlideShare a Scribd company logo
1 of 10
C# Tutorial
Part 10 :Collections
www.sirykt.blogspot.com
• In C#, collection represents group of objects. By the help of collections,
we can perform various operations on objects such as
• store object
• update object
• delete object
• retrieve object
• search object, and
• sort object
• In sort, all the data structure work can be performed by C# collections.
• We can store objects in array or collection. Collection has advantage over
array. Array has size limit but objects stored in collection can grow or
shrink dynamically.
• Types of Collections in C#
• There are 3 ways to work with collections. The three namespaces are
given below:
• System.Collections.Generic classes
• System.Collections classes (Now deprecated)
• System.Collections.Concurrent classes
• 1) System.Collections.Generic classes
• The System.Collections.Generic namespace has following classes:
• List
• Stack
• Queue
• LinkedList
• HashSet
• SortedSet
• Dictionary
• SortedDictionary
• SortedList
• 2) System.Collections classes
• These classes are legacy. It is suggested now to use System.Collections.Generic
classes. The System.Collections namespace has following classes:
• ArrayList
• Stack
• Queue
• Hashtable
• 3) System.Collections.Concurrent classes
• The System.Collections.Concurrent namespace provides classes for
thread-safe operations. Now multiple threads will not create problem for
accessing the collection items.
• The System.Collections.Concurrent namespace has following classes:
• BlockingCollection
• ConcurrentBag
• ConcurrentStack
• ConcurrentQueue
• ConcurrentDictionary
• Partitioner
• Partitioner
• OrderablePartitioner
• C# List<T> class is used to store and fetch elements. It can have
duplicate elements. It is found in System.Collections.Generic
namespace.
• C# HashSet class can be used to store, remove or view elements.
It does not store duplicate elements.
• It is suggested to use HashSet class if you have to store only
unique elements. It is found in System.Collections.Generic
namespace.
• C# SortedSet class can be used to store, remove or view elements.
It maintains ascending order and does not store duplicate elements.
• It is suggested to use SortedSet class if you have to store unique
elements and maintain ascending order. It is found in
System.Collections.Generic namespace.
• C# Stack<T> class is used to push and pop elements. It uses the
concept of Stack that arranges elements in LIFO (Last In First
Out) order.
• It can have duplicate elements. It is found in
System.Collections.Generic namespace.
• C# Queue<T> class is used to Enqueue and Dequeue elements. It
uses the concept of Queue that arranges elements in FIFO (First
In First Out) order.
• It can have duplicate elements. It is found in
System.Collections.Generic namespace.
• C# LinkedList<T> class uses the concept of linked list.
• It allows us to insert and delete elements fastly. It can have
duplicate elements. It is found in System.Collections.Generic
namespace.
• C# Dictionary<TKey, TValue> class uses the concept of hashtable.
It stores values on the basis of key.
• It contains unique keys only.
• By the help of key, we can easily search or remove elements.
• It is found in System.Collections.Generic namespace.
• C# SortedDictionary<TKey, TValue> class uses the concept of
hashtable.
• It stores values on the basis of key.
• It contains unique keys and maintains ascending order on the basis
of key.
• By the help of key, we can easily search or remove elements.
• It is found in System.Collections.Generic namespace.
• C# SortedList<TKey, TValue>
• C# SortedList<TKey, TValue> is an array of key/value pairs. It stores
values on the basis of key.
• The SortedList<TKey, TValue> class contains unique keys and maintains
ascending order on the basis of key.
• By the help of key, we can easily search or remove elements. It is found in
System.Collections.Generic namespace.
• It is like SortedDictionary<TKey, TValue> class.
• C# SortedList<TKey, TValue> vs SortedDictionary<TKey, TValue>
• SortedList<TKey, TValue> class uses less memory than
SortedDictionary<TKey, TValue>.
• It is recommended to use SortedList<TKey, TValue> if you have to store
and retrieve key/valye pairs.
• The SortedDictionary<TKey, TValue> class is faster than
SortedList<TKey, TValue> class if you perform insertion and removal for
SIRYKT
Sharing Knowledge is Learning
For more updates
For more visit our website www.sirykt.blogspot.com

More Related Content

What's hot

List interface in collections framework
List interface in collections frameworkList interface in collections framework
List interface in collections frameworkRavi Chythanya
 
PuppetConf 2017: Hiera 5: The Full Data Enchilada- Hendrik Lindberg, Puppet
PuppetConf 2017: Hiera 5: The Full Data Enchilada- Hendrik Lindberg, PuppetPuppetConf 2017: Hiera 5: The Full Data Enchilada- Hendrik Lindberg, Puppet
PuppetConf 2017: Hiera 5: The Full Data Enchilada- Hendrik Lindberg, PuppetPuppet
 
Collections - Maps
Collections - Maps Collections - Maps
Collections - Maps Hitesh-Java
 
Unit 1 array based implementation
Unit 1  array based implementationUnit 1  array based implementation
Unit 1 array based implementationLavanyaJ28
 
Types of Arrays
Types of ArraysTypes of Arrays
Types of ArraysAns Ali
 
How to Create an Array & types in PHP
How to Create an Array & types in PHP How to Create an Array & types in PHP
How to Create an Array & types in PHP Ajit Sinha
 
Collections Array list
Collections Array listCollections Array list
Collections Array listRatnaJava
 
Session 17 - Collections - Lists, Sets
Session 17 - Collections - Lists, SetsSession 17 - Collections - Lists, Sets
Session 17 - Collections - Lists, SetsPawanMM
 
Types by Adform Research, Saulius Valatka
Types by Adform Research, Saulius ValatkaTypes by Adform Research, Saulius Valatka
Types by Adform Research, Saulius ValatkaVasil Remeniuk
 

What's hot (18)

Collections Training
Collections TrainingCollections Training
Collections Training
 
Collections (1)
Collections (1)Collections (1)
Collections (1)
 
List interface in collections framework
List interface in collections frameworkList interface in collections framework
List interface in collections framework
 
Presentation of array
Presentation of arrayPresentation of array
Presentation of array
 
PuppetConf 2017: Hiera 5: The Full Data Enchilada- Hendrik Lindberg, Puppet
PuppetConf 2017: Hiera 5: The Full Data Enchilada- Hendrik Lindberg, PuppetPuppetConf 2017: Hiera 5: The Full Data Enchilada- Hendrik Lindberg, Puppet
PuppetConf 2017: Hiera 5: The Full Data Enchilada- Hendrik Lindberg, Puppet
 
Perl objects 101
Perl objects 101Perl objects 101
Perl objects 101
 
Collections - Maps
Collections - Maps Collections - Maps
Collections - Maps
 
Array in c
Array in cArray in c
Array in c
 
Unit 1 array based implementation
Unit 1  array based implementationUnit 1  array based implementation
Unit 1 array based implementation
 
Types of Arrays
Types of ArraysTypes of Arrays
Types of Arrays
 
Chapter 6 java
Chapter 6 javaChapter 6 java
Chapter 6 java
 
How to Create an Array & types in PHP
How to Create an Array & types in PHP How to Create an Array & types in PHP
How to Create an Array & types in PHP
 
Collections Array list
Collections Array listCollections Array list
Collections Array list
 
F sharp lists & dictionary
F sharp   lists &  dictionaryF sharp   lists &  dictionary
F sharp lists & dictionary
 
Session 17 - Collections - Lists, Sets
Session 17 - Collections - Lists, SetsSession 17 - Collections - Lists, Sets
Session 17 - Collections - Lists, Sets
 
Matlab Organizing Data
Matlab Organizing DataMatlab Organizing Data
Matlab Organizing Data
 
Types by Adform Research, Saulius Valatka
Types by Adform Research, Saulius ValatkaTypes by Adform Research, Saulius Valatka
Types by Adform Research, Saulius Valatka
 
Net framework
Net frameworkNet framework
Net framework
 

Similar to 9collection in c#

Similar to 9collection in c# (20)

12_-_Collections_Framework
12_-_Collections_Framework12_-_Collections_Framework
12_-_Collections_Framework
 
Java Programming Comprehensive Guide.pptx
Java Programming Comprehensive Guide.pptxJava Programming Comprehensive Guide.pptx
Java Programming Comprehensive Guide.pptx
 
Advanced c#
Advanced c#Advanced c#
Advanced c#
 
Standard template library
Standard template libraryStandard template library
Standard template library
 
Java Unit 2 (Part 2)
Java Unit 2 (Part 2)Java Unit 2 (Part 2)
Java Unit 2 (Part 2)
 
Java util
Java utilJava util
Java util
 
Javasession7
Javasession7Javasession7
Javasession7
 
STRINGS IN JAVA
STRINGS IN JAVASTRINGS IN JAVA
STRINGS IN JAVA
 
How to choose best containers in STL (C++)
How to choose best containers in STL (C++)How to choose best containers in STL (C++)
How to choose best containers in STL (C++)
 
C# Non generics collection
C# Non generics collectionC# Non generics collection
C# Non generics collection
 
DS Module1 (1).pptx
DS Module1 (1).pptxDS Module1 (1).pptx
DS Module1 (1).pptx
 
Standard Template Library
Standard Template LibraryStandard Template Library
Standard Template Library
 
Java 103 intro to java data structures
Java 103   intro to java data structuresJava 103   intro to java data structures
Java 103 intro to java data structures
 
Collections
CollectionsCollections
Collections
 
collections
 collections collections
collections
 
collection framework.pptx
collection framework.pptxcollection framework.pptx
collection framework.pptx
 
Icom4015 lecture14-f16
Icom4015 lecture14-f16Icom4015 lecture14-f16
Icom4015 lecture14-f16
 
Lists
ListsLists
Lists
 
Object Oriented Programming.pptx
Object Oriented Programming.pptxObject Oriented Programming.pptx
Object Oriented Programming.pptx
 
02._Object-Oriented_Programming_Concepts.ppt
02._Object-Oriented_Programming_Concepts.ppt02._Object-Oriented_Programming_Concepts.ppt
02._Object-Oriented_Programming_Concepts.ppt
 

More from Sireesh K (20)

Cn10
Cn10Cn10
Cn10
 
chanakya neeti
chanakya neetichanakya neeti
chanakya neeti
 
chanakya neeti
chanakya neetichanakya neeti
chanakya neeti
 
What is mvc
What is mvcWhat is mvc
What is mvc
 
31c
31c31c
31c
 
31cs
31cs31cs
31cs
 
45c
45c45c
45c
 
44c
44c44c
44c
 
43c
43c43c
43c
 
42c
42c42c
42c
 
41c
41c41c
41c
 
40c
40c40c
40c
 
39c
39c39c
39c
 
38c
38c38c
38c
 
37c
37c37c
37c
 
35c
35c35c
35c
 
34c
34c34c
34c
 
33c
33c33c
33c
 
30c
30c30c
30c
 
29c
29c29c
29c
 

Recently uploaded

Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...PsychoTech Services
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 

Recently uploaded (20)

Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 

9collection in c#

  • 1. C# Tutorial Part 10 :Collections www.sirykt.blogspot.com
  • 2. • In C#, collection represents group of objects. By the help of collections, we can perform various operations on objects such as • store object • update object • delete object • retrieve object • search object, and • sort object • In sort, all the data structure work can be performed by C# collections. • We can store objects in array or collection. Collection has advantage over array. Array has size limit but objects stored in collection can grow or shrink dynamically. • Types of Collections in C# • There are 3 ways to work with collections. The three namespaces are given below: • System.Collections.Generic classes • System.Collections classes (Now deprecated) • System.Collections.Concurrent classes
  • 3. • 1) System.Collections.Generic classes • The System.Collections.Generic namespace has following classes: • List • Stack • Queue • LinkedList • HashSet • SortedSet • Dictionary • SortedDictionary • SortedList • 2) System.Collections classes • These classes are legacy. It is suggested now to use System.Collections.Generic classes. The System.Collections namespace has following classes: • ArrayList • Stack • Queue • Hashtable
  • 4. • 3) System.Collections.Concurrent classes • The System.Collections.Concurrent namespace provides classes for thread-safe operations. Now multiple threads will not create problem for accessing the collection items. • The System.Collections.Concurrent namespace has following classes: • BlockingCollection • ConcurrentBag • ConcurrentStack • ConcurrentQueue • ConcurrentDictionary • Partitioner • Partitioner • OrderablePartitioner
  • 5. • C# List<T> class is used to store and fetch elements. It can have duplicate elements. It is found in System.Collections.Generic namespace. • C# HashSet class can be used to store, remove or view elements. It does not store duplicate elements. • It is suggested to use HashSet class if you have to store only unique elements. It is found in System.Collections.Generic namespace. • C# SortedSet class can be used to store, remove or view elements. It maintains ascending order and does not store duplicate elements. • It is suggested to use SortedSet class if you have to store unique elements and maintain ascending order. It is found in System.Collections.Generic namespace.
  • 6. • C# Stack<T> class is used to push and pop elements. It uses the concept of Stack that arranges elements in LIFO (Last In First Out) order. • It can have duplicate elements. It is found in System.Collections.Generic namespace. • C# Queue<T> class is used to Enqueue and Dequeue elements. It uses the concept of Queue that arranges elements in FIFO (First In First Out) order. • It can have duplicate elements. It is found in System.Collections.Generic namespace. • C# LinkedList<T> class uses the concept of linked list. • It allows us to insert and delete elements fastly. It can have duplicate elements. It is found in System.Collections.Generic namespace.
  • 7. • C# Dictionary<TKey, TValue> class uses the concept of hashtable. It stores values on the basis of key. • It contains unique keys only. • By the help of key, we can easily search or remove elements. • It is found in System.Collections.Generic namespace. • C# SortedDictionary<TKey, TValue> class uses the concept of hashtable. • It stores values on the basis of key. • It contains unique keys and maintains ascending order on the basis of key. • By the help of key, we can easily search or remove elements. • It is found in System.Collections.Generic namespace.
  • 8. • C# SortedList<TKey, TValue> • C# SortedList<TKey, TValue> is an array of key/value pairs. It stores values on the basis of key. • The SortedList<TKey, TValue> class contains unique keys and maintains ascending order on the basis of key. • By the help of key, we can easily search or remove elements. It is found in System.Collections.Generic namespace. • It is like SortedDictionary<TKey, TValue> class. • C# SortedList<TKey, TValue> vs SortedDictionary<TKey, TValue> • SortedList<TKey, TValue> class uses less memory than SortedDictionary<TKey, TValue>. • It is recommended to use SortedList<TKey, TValue> if you have to store and retrieve key/valye pairs. • The SortedDictionary<TKey, TValue> class is faster than SortedList<TKey, TValue> class if you perform insertion and removal for
  • 10. For more updates For more visit our website www.sirykt.blogspot.com