SlideShare a Scribd company logo
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

DOCX
C# Collection classes
MohitKumar1985
 
PPT
Core & advanced java classes in mumbai
Vibrant Technologies & Computers
 
PPTX
Array list(1)
abdullah619
 
PDF
Array list (java platform se 8 )
charan kumar
 
PPTX
Java Chapter 05 - Conditions & Loops: part 7
DanWooster1
 
PPTX
Arrays
sana younas
 
PPSX
Net framework session02
Vivek Singh Chandel
 
PPTX
C# Generic collections
Prem Kumar Badri
 
C# Collection classes
MohitKumar1985
 
Core & advanced java classes in mumbai
Vibrant Technologies & Computers
 
Array list(1)
abdullah619
 
Array list (java platform se 8 )
charan kumar
 
Java Chapter 05 - Conditions & Loops: part 7
DanWooster1
 
Arrays
sana younas
 
Net framework session02
Vivek Singh Chandel
 
C# Generic collections
Prem Kumar Badri
 

What's hot (18)

PPTX
Collections Training
Ramindu Deshapriya
 
PPTX
Collections (1)
abdullah619
 
PPTX
List interface in collections framework
Ravi Chythanya
 
PPT
Presentation of array
Shamim Hossain
 
PDF
PuppetConf 2017: Hiera 5: The Full Data Enchilada- Hendrik Lindberg, Puppet
Puppet
 
PDF
Perl objects 101
Craig Treptow
 
PPSX
Collections - Maps
Hitesh-Java
 
PPTX
Array in c
Harsh Bhanushali
 
PPTX
Unit 1 array based implementation
LavanyaJ28
 
PPTX
Types of Arrays
Ans Ali
 
PPTX
Chapter 6 java
Ahmad sohail Kakar
 
PPTX
How to Create an Array & types in PHP
Ajit Sinha
 
PPTX
Collections Array list
RatnaJava
 
PPTX
F sharp lists & dictionary
DrRajeshreeKhande
 
PPTX
Session 17 - Collections - Lists, Sets
PawanMM
 
PPTX
Matlab Organizing Data
DataminingTools Inc
 
PPTX
Types by Adform Research, Saulius Valatka
Vasil Remeniuk
 
PPTX
Net framework
Abhishek Mukherjee
 
Collections Training
Ramindu Deshapriya
 
Collections (1)
abdullah619
 
List interface in collections framework
Ravi Chythanya
 
Presentation of array
Shamim Hossain
 
PuppetConf 2017: Hiera 5: The Full Data Enchilada- Hendrik Lindberg, Puppet
Puppet
 
Perl objects 101
Craig Treptow
 
Collections - Maps
Hitesh-Java
 
Array in c
Harsh Bhanushali
 
Unit 1 array based implementation
LavanyaJ28
 
Types of Arrays
Ans Ali
 
Chapter 6 java
Ahmad sohail Kakar
 
How to Create an Array & types in PHP
Ajit Sinha
 
Collections Array list
RatnaJava
 
F sharp lists & dictionary
DrRajeshreeKhande
 
Session 17 - Collections - Lists, Sets
PawanMM
 
Matlab Organizing Data
DataminingTools Inc
 
Types by Adform Research, Saulius Valatka
Vasil Remeniuk
 
Net framework
Abhishek Mukherjee
 
Ad

Similar to 9collection in c# (20)

PPTX
COLLECTIONS.pptx
SruthyPJ
 
PPT
Generics collections
Yaswanth Babu Gummadivelli
 
PPTX
Collections in .net technology (2160711)
Janki Shah
 
PPTX
Collection
Gayathri Ganesh
 
PPS
Net framework session02
Niit Care
 
PPT
Generics Collections
phanleson
 
PPTX
Collections and generics
Miguel Angel Teheran Garcia
 
PPTX
Collections and its types in C# (with examples)
Aijaz Ali Abro
 
PPTX
CSharp for Unity - Day 1
Duong Thanh
 
DOCX
Collections generic
sandhish
 
PPTX
C# Non generics collection
Prem Kumar Badri
 
PPT
Collections
niksomer
 
PDF
LectureNotes-03-DSA
Haitham El-Ghareeb
 
PPT
Advanced c#
AkashThakrar
 
PPTX
Module 8 : Implementing collections and generics
Prem Kumar Badri
 
PPTX
Generic Programming &amp; Collection
Arya
 
PPTX
Generic Programming &amp; Collection
Arya
 
PDF
C# Starter L04-Collections
Mohammad Shaker
 
ODP
(4) collections algorithms
Nico Ludwig
 
PPTX
Generics In and Out
Jaliya Udagedara
 
COLLECTIONS.pptx
SruthyPJ
 
Generics collections
Yaswanth Babu Gummadivelli
 
Collections in .net technology (2160711)
Janki Shah
 
Collection
Gayathri Ganesh
 
Net framework session02
Niit Care
 
Generics Collections
phanleson
 
Collections and generics
Miguel Angel Teheran Garcia
 
Collections and its types in C# (with examples)
Aijaz Ali Abro
 
CSharp for Unity - Day 1
Duong Thanh
 
Collections generic
sandhish
 
C# Non generics collection
Prem Kumar Badri
 
Collections
niksomer
 
LectureNotes-03-DSA
Haitham El-Ghareeb
 
Advanced c#
AkashThakrar
 
Module 8 : Implementing collections and generics
Prem Kumar Badri
 
Generic Programming &amp; Collection
Arya
 
Generic Programming &amp; Collection
Arya
 
C# Starter L04-Collections
Mohammad Shaker
 
(4) collections algorithms
Nico Ludwig
 
Generics In and Out
Jaliya Udagedara
 
Ad

More from Sireesh K (20)

PPTX
Cn10
Sireesh K
 
PPTX
chanakya neeti
Sireesh K
 
PPTX
chanakya neeti
Sireesh K
 
DOCX
What is mvc
Sireesh K
 
PPTX
31c
Sireesh K
 
PPTX
31cs
Sireesh K
 
PPTX
45c
Sireesh K
 
PPTX
44c
Sireesh K
 
PPTX
43c
Sireesh K
 
PPTX
42c
Sireesh K
 
PPTX
41c
Sireesh K
 
PPTX
40c
Sireesh K
 
PPTX
39c
Sireesh K
 
PPTX
38c
Sireesh K
 
PPTX
37c
Sireesh K
 
PPTX
35c
Sireesh K
 
PPTX
34c
Sireesh K
 
PPTX
33c
Sireesh K
 
PPTX
30c
Sireesh K
 
PPTX
29c
Sireesh K
 
Cn10
Sireesh K
 
chanakya neeti
Sireesh K
 
chanakya neeti
Sireesh K
 
What is mvc
Sireesh K
 
31cs
Sireesh K
 

Recently uploaded (20)

PPTX
Command Palatte in Odoo 18.1 Spreadsheet - Odoo Slides
Celine George
 
DOCX
Modul Ajar Deep Learning Bahasa Inggris Kelas 11 Terbaru 2025
wahyurestu63
 
PPTX
A Smarter Way to Think About Choosing a College
Cyndy McDonald
 
PDF
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
PPTX
Kanban Cards _ Mass Action in Odoo 18.2 - Odoo Slides
Celine George
 
PPTX
20250924 Navigating the Future: How to tell the difference between an emergen...
McGuinness Institute
 
PPTX
Artificial Intelligence in Gastroentrology: Advancements and Future Presprec...
AyanHossain
 
PPTX
Continental Accounting in Odoo 18 - Odoo Slides
Celine George
 
PPTX
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 
PPTX
Introduction to pediatric nursing in 5th Sem..pptx
AneetaSharma15
 
PPTX
Five Point Someone – Chetan Bhagat | Book Summary & Analysis by Bhupesh Kushwaha
Bhupesh Kushwaha
 
PPTX
HEALTH CARE DELIVERY SYSTEM - UNIT 2 - GNM 3RD YEAR.pptx
Priyanshu Anand
 
PPTX
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
PoojaSen20
 
PPTX
CONCEPT OF CHILD CARE. pptx
AneetaSharma15
 
PPTX
Basics and rules of probability with real-life uses
ravatkaran694
 
PPTX
Virus sequence retrieval from NCBI database
yamunaK13
 
PPTX
PROTIEN ENERGY MALNUTRITION: NURSING MANAGEMENT.pptx
PRADEEP ABOTHU
 
PPTX
INTESTINALPARASITES OR WORM INFESTATIONS.pptx
PRADEEP ABOTHU
 
PDF
Virat Kohli- the Pride of Indian cricket
kushpar147
 
PPTX
Measures_of_location_-_Averages_and__percentiles_by_DR SURYA K.pptx
Surya Ganesh
 
Command Palatte in Odoo 18.1 Spreadsheet - Odoo Slides
Celine George
 
Modul Ajar Deep Learning Bahasa Inggris Kelas 11 Terbaru 2025
wahyurestu63
 
A Smarter Way to Think About Choosing a College
Cyndy McDonald
 
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
Kanban Cards _ Mass Action in Odoo 18.2 - Odoo Slides
Celine George
 
20250924 Navigating the Future: How to tell the difference between an emergen...
McGuinness Institute
 
Artificial Intelligence in Gastroentrology: Advancements and Future Presprec...
AyanHossain
 
Continental Accounting in Odoo 18 - Odoo Slides
Celine George
 
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 
Introduction to pediatric nursing in 5th Sem..pptx
AneetaSharma15
 
Five Point Someone – Chetan Bhagat | Book Summary & Analysis by Bhupesh Kushwaha
Bhupesh Kushwaha
 
HEALTH CARE DELIVERY SYSTEM - UNIT 2 - GNM 3RD YEAR.pptx
Priyanshu Anand
 
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
PoojaSen20
 
CONCEPT OF CHILD CARE. pptx
AneetaSharma15
 
Basics and rules of probability with real-life uses
ravatkaran694
 
Virus sequence retrieval from NCBI database
yamunaK13
 
PROTIEN ENERGY MALNUTRITION: NURSING MANAGEMENT.pptx
PRADEEP ABOTHU
 
INTESTINALPARASITES OR WORM INFESTATIONS.pptx
PRADEEP ABOTHU
 
Virat Kohli- the Pride of Indian cricket
kushpar147
 
Measures_of_location_-_Averages_and__percentiles_by_DR SURYA K.pptx
Surya Ganesh
 

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