SlideShare a Scribd company logo
2
Most read
3
Most read
4
Most read
Generic Collections
1
• What Are Collections?
• What Are Generic Collections?
2
What Are Collections?
• Collections store arbitrary objects in a structured manner.
Types of collections available within the .NET Framework are:
 Arrays
 Advanced collections
 Non-generic collections
 Generic collections
3
What Are Generic Collections?
• Generic collections support the storage of both value
types and reference types. Only a single data type is
allowed to be stored inside a generic collection. Following
are the generic collection types:
Generic Dictionary
Generic List
Generic Stack
Generic Queue
Generic LinkedList
Generic Interface
4
• Generic List class
Provides methods to search, sort, and manipulate the elements
of a generic list.
• Generic Stack Class
The generic Stack class represents a variable size LIFO collection
of objects of same data type.
• Generic Queue Class
The generic Queue class represents a variable size FIFO
collection of elements of same data type.
5
• The .NET Framework provides the following classes in the
System.Collections.Generic namespace that help you to add
name and value pairs to a collection:
Dictionary
SortedList
SortedDictionary
6
Examples
Generic List
List<T> Var_name = new List<T>();
Generic Stack
Stack<string> names = new Stack<string>();
names.Push("A");
names.Push("B");
foreach (string name in names)
{
Console.WriteLine(name);
}
7
Generic Queue
Queue<int> ticketNos =new Queue<int>();
ticketNos.Enqueue(100);
ticketNos.Enqueue(200);
ticketNos.Enqueue(300);
ticketNos.Enqueue(400);
foreach (int tno in ticketNos )
{
Console.WriteLine(tno);
}
8
HashTable
Hashtable table = new Hashtable();
table.Add(1,"one value");
table.Add(2, "Two value");
table.Add(3, "Three value");
foreach (var item in table.Keys )
{
Console.WriteLine(table [item]);
}
table.Remove(2);
9
Dictionary
Dictionary<int, string> CityNames = new Dictionary<int, string>();
CityNames.Add(1,"asdasd");
CityNames.Add(2, "gggg");
CityNames.Add(3, "rtyy");
foreach (int key in CityNames .Keys )
{
Console.WriteLine( "City Name {0}",CityNames [key]);
}
10
Thank You
11

More Related Content

What's hot (20)

PPT
Hibernate architecture
Anurag
 
PPTX
JSON and XML
People Strategists
 
PPTX
Html5 and-css3-overview
Jacob Nelson
 
PDF
Basics of JavaScript
Bala Narayanan
 
PPTX
React dom
ShahriarPriyo
 
PDF
Lambda Expressions in Java
Erhan Bagdemir
 
PPTX
PHP FUNCTIONS
Zeeshan Ahmed
 
PPT
Exception Handling in JAVA
SURIT DATTA
 
PPT
Java Collections Framework
Sony India Software Center
 
PPT
Jsp ppt
Vikas Jagtap
 
PPTX
ReactJS presentation.pptx
DivyanshGupta922023
 
PPTX
Hibernate ppt
Aneega
 
PPT
Introduction to JavaScript (1).ppt
MuhammadRehan856177
 
PPTX
MongoDB
nikhil2807
 
PDF
Hibernate Presentation
guest11106b
 
PPTX
jQuery PPT
Dominic Arrojado
 
PPT
Java collection
Arati Gadgil
 
PPTX
NOSQL Databases types and Uses
Suvradeep Rudra
 
PPTX
Reactjs
Mallikarjuna G D
 
Hibernate architecture
Anurag
 
JSON and XML
People Strategists
 
Html5 and-css3-overview
Jacob Nelson
 
Basics of JavaScript
Bala Narayanan
 
React dom
ShahriarPriyo
 
Lambda Expressions in Java
Erhan Bagdemir
 
PHP FUNCTIONS
Zeeshan Ahmed
 
Exception Handling in JAVA
SURIT DATTA
 
Java Collections Framework
Sony India Software Center
 
Jsp ppt
Vikas Jagtap
 
ReactJS presentation.pptx
DivyanshGupta922023
 
Hibernate ppt
Aneega
 
Introduction to JavaScript (1).ppt
MuhammadRehan856177
 
MongoDB
nikhil2807
 
Hibernate Presentation
guest11106b
 
jQuery PPT
Dominic Arrojado
 
Java collection
Arati Gadgil
 
NOSQL Databases types and Uses
Suvradeep Rudra
 

Similar to C# Generic collections (20)

DOCX
Collections generic
sandhish
 
PPT
Collections
niksomer
 
PPTX
Module 8 : Implementing collections and generics
Prem Kumar Badri
 
PPSX
Net framework session02
Vivek Singh Chandel
 
PPTX
collections
Yaswanth Babu Gummadivelli
 
PPTX
Generics In and Out
Jaliya Udagedara
 
ODP
(4) collections algorithms
Nico Ludwig
 
PDF
(4) collections algorithms
Nico Ludwig
 
PPT
Generics collections
Yaswanth Babu Gummadivelli
 
PPS
Net framework session02
Niit Care
 
PPT
Generics Collections
phanleson
 
PPTX
C# Non generics collection
Prem Kumar Badri
 
PPTX
Collections (1)
abdullah619
 
PPTX
Collection
Gayathri Ganesh
 
PPTX
Collections in .net technology (2160711)
Janki Shah
 
PPTX
COLLECTIONS.pptx
SruthyPJ
 
PPS
Introduction To .Net
Soumya Ramachandran
 
PPTX
9collection in c#
Sireesh K
 
PDF
Review of c_sharp2_features_part_i
Nico Ludwig
 
PDF
C# quick ref (bruce 2016)
Bruce Hantover
 
Collections generic
sandhish
 
Collections
niksomer
 
Module 8 : Implementing collections and generics
Prem Kumar Badri
 
Net framework session02
Vivek Singh Chandel
 
Generics In and Out
Jaliya Udagedara
 
(4) collections algorithms
Nico Ludwig
 
(4) collections algorithms
Nico Ludwig
 
Generics collections
Yaswanth Babu Gummadivelli
 
Net framework session02
Niit Care
 
Generics Collections
phanleson
 
C# Non generics collection
Prem Kumar Badri
 
Collections (1)
abdullah619
 
Collection
Gayathri Ganesh
 
Collections in .net technology (2160711)
Janki Shah
 
COLLECTIONS.pptx
SruthyPJ
 
Introduction To .Net
Soumya Ramachandran
 
9collection in c#
Sireesh K
 
Review of c_sharp2_features_part_i
Nico Ludwig
 
C# quick ref (bruce 2016)
Bruce Hantover
 
Ad

More from Prem Kumar Badri (20)

PPTX
Module 15 attributes
Prem Kumar Badri
 
PPTX
Module 14 properties and indexers
Prem Kumar Badri
 
PPTX
Module 12 aggregation, namespaces, and advanced scope
Prem Kumar Badri
 
PPTX
Module 13 operators, delegates, and events
Prem Kumar Badri
 
PPTX
Module 11 : Inheritance
Prem Kumar Badri
 
PPTX
Module 10 : creating and destroying objects
Prem Kumar Badri
 
PPTX
Module 9 : using reference type variables
Prem Kumar Badri
 
PPTX
Module 7 : Arrays
Prem Kumar Badri
 
PPTX
Module 6 : Essentials of Object Oriented Programming
Prem Kumar Badri
 
PPTX
Module 5 : Statements & Exceptions
Prem Kumar Badri
 
PPTX
Module 4 : methods & parameters
Prem Kumar Badri
 
PPTX
Module 3 : using value type variables
Prem Kumar Badri
 
PPTX
Module 2: Overview of c#
Prem Kumar Badri
 
PPTX
Module 1 : Overview of the Microsoft .NET Platform
Prem Kumar Badri
 
PPTX
C# Multi threading
Prem Kumar Badri
 
PPT
C# Method overloading
Prem Kumar Badri
 
PPTX
C# Inheritance
Prem Kumar Badri
 
PPTX
C# Global Assembly Cache
Prem Kumar Badri
 
PPTX
C# Filtering in generic collections
Prem Kumar Badri
 
PPTX
C# File IO Operations
Prem Kumar Badri
 
Module 15 attributes
Prem Kumar Badri
 
Module 14 properties and indexers
Prem Kumar Badri
 
Module 12 aggregation, namespaces, and advanced scope
Prem Kumar Badri
 
Module 13 operators, delegates, and events
Prem Kumar Badri
 
Module 11 : Inheritance
Prem Kumar Badri
 
Module 10 : creating and destroying objects
Prem Kumar Badri
 
Module 9 : using reference type variables
Prem Kumar Badri
 
Module 7 : Arrays
Prem Kumar Badri
 
Module 6 : Essentials of Object Oriented Programming
Prem Kumar Badri
 
Module 5 : Statements & Exceptions
Prem Kumar Badri
 
Module 4 : methods & parameters
Prem Kumar Badri
 
Module 3 : using value type variables
Prem Kumar Badri
 
Module 2: Overview of c#
Prem Kumar Badri
 
Module 1 : Overview of the Microsoft .NET Platform
Prem Kumar Badri
 
C# Multi threading
Prem Kumar Badri
 
C# Method overloading
Prem Kumar Badri
 
C# Inheritance
Prem Kumar Badri
 
C# Global Assembly Cache
Prem Kumar Badri
 
C# Filtering in generic collections
Prem Kumar Badri
 
C# File IO Operations
Prem Kumar Badri
 
Ad

Recently uploaded (20)

PPTX
INTESTINALPARASITES OR WORM INFESTATIONS.pptx
PRADEEP ABOTHU
 
PDF
EXCRETION-STRUCTURE OF NEPHRON,URINE FORMATION
raviralanaresh2
 
PDF
My Thoughts On Q&A- A Novel By Vikas Swarup
Niharika
 
PPTX
IDEAS AND EARLY STATES Social science pptx
NIRANJANASSURESH
 
PPT
DRUGS USED IN THERAPY OF SHOCK, Shock Therapy, Treatment or management of shock
Rajshri Ghogare
 
DOCX
Modul Ajar Deep Learning Bahasa Inggris Kelas 11 Terbaru 2025
wahyurestu63
 
PPTX
Sonnet 130_ My Mistress’ Eyes Are Nothing Like the Sun By William Shakespear...
DhatriParmar
 
PDF
A guide to responding to Section C essay tasks for the VCE English Language E...
jpinnuck
 
PDF
Exploring-the-Investigative-World-of-Science.pdf/8th class curiosity/1st chap...
Sandeep Swamy
 
PPTX
The Future of Artificial Intelligence Opportunities and Risks Ahead
vaghelajayendra784
 
PPTX
THE JEHOVAH’S WITNESSES’ ENCRYPTED SATANIC CULT
Claude LaCombe
 
PPTX
Cybersecurity: How to Protect your Digital World from Hackers
vaidikpanda4
 
PDF
TOP 10 AI TOOLS YOU MUST LEARN TO SURVIVE IN 2025 AND ABOVE
digilearnings.com
 
PPTX
20250924 Navigating the Future: How to tell the difference between an emergen...
McGuinness Institute
 
PPTX
CONCEPT OF CHILD CARE. pptx
AneetaSharma15
 
PPTX
Applied-Statistics-1.pptx hardiba zalaaa
hardizala899
 
PPTX
Constitutional Design Civics Class 9.pptx
bikesh692
 
PPTX
Various Psychological tests: challenges and contemporary trends in psychologi...
santoshmohalik1
 
PDF
Tips for Writing the Research Title with Examples
Thelma Villaflores
 
PPTX
10CLA Term 3 Week 4 Study Techniques.pptx
mansk2
 
INTESTINALPARASITES OR WORM INFESTATIONS.pptx
PRADEEP ABOTHU
 
EXCRETION-STRUCTURE OF NEPHRON,URINE FORMATION
raviralanaresh2
 
My Thoughts On Q&A- A Novel By Vikas Swarup
Niharika
 
IDEAS AND EARLY STATES Social science pptx
NIRANJANASSURESH
 
DRUGS USED IN THERAPY OF SHOCK, Shock Therapy, Treatment or management of shock
Rajshri Ghogare
 
Modul Ajar Deep Learning Bahasa Inggris Kelas 11 Terbaru 2025
wahyurestu63
 
Sonnet 130_ My Mistress’ Eyes Are Nothing Like the Sun By William Shakespear...
DhatriParmar
 
A guide to responding to Section C essay tasks for the VCE English Language E...
jpinnuck
 
Exploring-the-Investigative-World-of-Science.pdf/8th class curiosity/1st chap...
Sandeep Swamy
 
The Future of Artificial Intelligence Opportunities and Risks Ahead
vaghelajayendra784
 
THE JEHOVAH’S WITNESSES’ ENCRYPTED SATANIC CULT
Claude LaCombe
 
Cybersecurity: How to Protect your Digital World from Hackers
vaidikpanda4
 
TOP 10 AI TOOLS YOU MUST LEARN TO SURVIVE IN 2025 AND ABOVE
digilearnings.com
 
20250924 Navigating the Future: How to tell the difference between an emergen...
McGuinness Institute
 
CONCEPT OF CHILD CARE. pptx
AneetaSharma15
 
Applied-Statistics-1.pptx hardiba zalaaa
hardizala899
 
Constitutional Design Civics Class 9.pptx
bikesh692
 
Various Psychological tests: challenges and contemporary trends in psychologi...
santoshmohalik1
 
Tips for Writing the Research Title with Examples
Thelma Villaflores
 
10CLA Term 3 Week 4 Study Techniques.pptx
mansk2
 

C# Generic collections

  • 2. • What Are Collections? • What Are Generic Collections? 2
  • 3. What Are Collections? • Collections store arbitrary objects in a structured manner. Types of collections available within the .NET Framework are:  Arrays  Advanced collections  Non-generic collections  Generic collections 3
  • 4. What Are Generic Collections? • Generic collections support the storage of both value types and reference types. Only a single data type is allowed to be stored inside a generic collection. Following are the generic collection types: Generic Dictionary Generic List Generic Stack Generic Queue Generic LinkedList Generic Interface 4
  • 5. • Generic List class Provides methods to search, sort, and manipulate the elements of a generic list. • Generic Stack Class The generic Stack class represents a variable size LIFO collection of objects of same data type. • Generic Queue Class The generic Queue class represents a variable size FIFO collection of elements of same data type. 5
  • 6. • The .NET Framework provides the following classes in the System.Collections.Generic namespace that help you to add name and value pairs to a collection: Dictionary SortedList SortedDictionary 6
  • 7. Examples Generic List List<T> Var_name = new List<T>(); Generic Stack Stack<string> names = new Stack<string>(); names.Push("A"); names.Push("B"); foreach (string name in names) { Console.WriteLine(name); } 7
  • 8. Generic Queue Queue<int> ticketNos =new Queue<int>(); ticketNos.Enqueue(100); ticketNos.Enqueue(200); ticketNos.Enqueue(300); ticketNos.Enqueue(400); foreach (int tno in ticketNos ) { Console.WriteLine(tno); } 8
  • 9. HashTable Hashtable table = new Hashtable(); table.Add(1,"one value"); table.Add(2, "Two value"); table.Add(3, "Three value"); foreach (var item in table.Keys ) { Console.WriteLine(table [item]); } table.Remove(2); 9
  • 10. Dictionary Dictionary<int, string> CityNames = new Dictionary<int, string>(); CityNames.Add(1,"asdasd"); CityNames.Add(2, "gggg"); CityNames.Add(3, "rtyy"); foreach (int key in CityNames .Keys ) { Console.WriteLine( "City Name {0}",CityNames [key]); } 10