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
PPT
Core & advanced java classes in mumbai
PPTX
Array list(1)
PDF
Array list (java platform se 8 )
PPTX
Java Chapter 05 - Conditions & Loops: part 7
PPTX
Arrays
PPSX
Net framework session02
PPTX
C# Generic collections
C# Collection classes
Core & advanced java classes in mumbai
Array list(1)
Array list (java platform se 8 )
Java Chapter 05 - Conditions & Loops: part 7
Arrays
Net framework session02
C# Generic collections

What's hot (18)

PPTX
Collections Training
PPTX
Collections (1)
PPTX
List interface in collections framework
PPT
Presentation of array
PDF
PuppetConf 2017: Hiera 5: The Full Data Enchilada- Hendrik Lindberg, Puppet
PDF
Perl objects 101
PPSX
Collections - Maps
PPTX
Array in c
PPTX
Unit 1 array based implementation
PPTX
Types of Arrays
PPTX
Chapter 6 java
PPTX
How to Create an Array & types in PHP
PPTX
Collections Array list
PPTX
F sharp lists & dictionary
PPTX
Session 17 - Collections - Lists, Sets
PPTX
Matlab Organizing Data
PPTX
Types by Adform Research, Saulius Valatka
PPTX
Net framework
Collections Training
Collections (1)
List interface in collections framework
Presentation of array
PuppetConf 2017: Hiera 5: The Full Data Enchilada- Hendrik Lindberg, Puppet
Perl objects 101
Collections - Maps
Array in c
Unit 1 array based implementation
Types of Arrays
Chapter 6 java
How to Create an Array & types in PHP
Collections Array list
F sharp lists & dictionary
Session 17 - Collections - Lists, Sets
Matlab Organizing Data
Types by Adform Research, Saulius Valatka
Net framework
Ad

Similar to 9collection in c# (20)

PPTX
COLLECTIONS.pptx
PPT
Generics collections
PPTX
Collections in .net technology (2160711)
PPTX
Collection
PPS
Net framework session02
PPT
Generics Collections
PPTX
Collections and generics
PPTX
Collections and its types in C# (with examples)
PPTX
CSharp for Unity - Day 1
DOCX
Collections generic
PPTX
C# Non generics collection
PPT
Collections
PDF
LectureNotes-03-DSA
PPT
Advanced c#
PPTX
Module 8 : Implementing collections and generics
PPTX
Generic Programming &amp; Collection
PPTX
Generic Programming &amp; Collection
PDF
C# Starter L04-Collections
ODP
(4) collections algorithms
PPTX
Generics In and Out
COLLECTIONS.pptx
Generics collections
Collections in .net technology (2160711)
Collection
Net framework session02
Generics Collections
Collections and generics
Collections and its types in C# (with examples)
CSharp for Unity - Day 1
Collections generic
C# Non generics collection
Collections
LectureNotes-03-DSA
Advanced c#
Module 8 : Implementing collections and generics
Generic Programming &amp; Collection
Generic Programming &amp; Collection
C# Starter L04-Collections
(4) collections algorithms
Generics In and Out
Ad

More from Sireesh K (20)

PPTX
Cn10
PPTX
chanakya neeti
PPTX
chanakya neeti
DOCX
What is mvc
PPTX
PPTX
31cs
PPTX
PPTX
PPTX
PPTX
PPTX
PPTX
PPTX
PPTX
PPTX
PPTX
PPTX
PPTX
PPTX
PPTX
Cn10
chanakya neeti
chanakya neeti
What is mvc
31cs

Recently uploaded (20)

PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PPTX
A powerpoint presentation on the Revised K-10 Science Shaping Paper
PDF
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
PPTX
CHAPTER IV. MAN AND BIOSPHERE AND ITS TOTALITY.pptx
PPTX
UV-Visible spectroscopy..pptx UV-Visible Spectroscopy – Electronic Transition...
PPTX
Radiologic_Anatomy_of_the_Brachial_plexus [final].pptx
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
Lesson notes of climatology university.
PPTX
Cell Types and Its function , kingdom of life
PDF
Computing-Curriculum for Schools in Ghana
PPTX
Digestion and Absorption of Carbohydrates, Proteina and Fats
PDF
Weekly quiz Compilation Jan -July 25.pdf
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PPTX
Introduction to Building Materials
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PDF
LNK 2025 (2).pdf MWEHEHEHEHEHEHEHEHEHEHE
PDF
IGGE1 Understanding the Self1234567891011
PPTX
UNIT III MENTAL HEALTH NURSING ASSESSMENT
PDF
Trump Administration's workforce development strategy
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
A powerpoint presentation on the Revised K-10 Science Shaping Paper
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
CHAPTER IV. MAN AND BIOSPHERE AND ITS TOTALITY.pptx
UV-Visible spectroscopy..pptx UV-Visible Spectroscopy – Electronic Transition...
Radiologic_Anatomy_of_the_Brachial_plexus [final].pptx
Final Presentation General Medicine 03-08-2024.pptx
Lesson notes of climatology university.
Cell Types and Its function , kingdom of life
Computing-Curriculum for Schools in Ghana
Digestion and Absorption of Carbohydrates, Proteina and Fats
Weekly quiz Compilation Jan -July 25.pdf
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
Introduction to Building Materials
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
LNK 2025 (2).pdf MWEHEHEHEHEHEHEHEHEHEHE
IGGE1 Understanding the Self1234567891011
UNIT III MENTAL HEALTH NURSING ASSESSMENT
Trump Administration's workforce development strategy

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