SlideShare a Scribd company logo
3
Most read
4
Most read
7
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)

PDF
TypeScript Introduction
Dmitry Sheiko
 
PPTX
interface in c#
Deepti Pillai
 
PPT
Collection Framework in java
CPD INDIA
 
PPTX
Java - Collections framework
Riccardo Cardin
 
PPTX
Collections and its types in C# (with examples)
Aijaz Ali Abro
 
PDF
Collections In Java
Binoj T E
 
PPT
Collections in Java
Khasim Cise
 
PPTX
JAVA AWT
shanmuga rajan
 
PDF
Alarms
maamir farooq
 
PPT
Ajax Presentation
alaa.moustafa
 
PPTX
Pure virtual function and abstract class
Amit Trivedi
 
PPTX
Event Handling in java
Google
 
PPTX
An Introduction To REST API
Aniruddh Bhilvare
 
PPTX
Servlets
ZainabNoorGul
 
PPT
Java collection
Arati Gadgil
 
PPTX
React workshop
Imran Sayed
 
PPTX
Delegates and events in C#
Dr.Neeraj Kumar Pandey
 
PPTX
Collections in-csharp
Lakshmi Mareddy
 
TypeScript Introduction
Dmitry Sheiko
 
interface in c#
Deepti Pillai
 
Collection Framework in java
CPD INDIA
 
Java - Collections framework
Riccardo Cardin
 
Collections and its types in C# (with examples)
Aijaz Ali Abro
 
Collections In Java
Binoj T E
 
Collections in Java
Khasim Cise
 
JAVA AWT
shanmuga rajan
 
Ajax Presentation
alaa.moustafa
 
Pure virtual function and abstract class
Amit Trivedi
 
Event Handling in java
Google
 
An Introduction To REST API
Aniruddh Bhilvare
 
Servlets
ZainabNoorGul
 
Java collection
Arati Gadgil
 
React workshop
Imran Sayed
 
Delegates and events in C#
Dr.Neeraj Kumar Pandey
 
Collections in-csharp
Lakshmi Mareddy
 

Similar to C# Generic collections (20)

PPT
Collections
niksomer
 
PPTX
Module 8 : Implementing collections and generics
Prem Kumar Badri
 
PPSX
Net framework session02
Vivek Singh Chandel
 
PPTX
9collection in c#
Sireesh K
 
PPTX
Collections (1)
abdullah619
 
PPTX
Java Collections Framework - Interfaces, Classes and Algorithms
RajalakshmiS74
 
PPS
Introduction To .Net
Soumya Ramachandran
 
PDF
Java collections
padmad2291
 
PPT
Dewey Classification
Denise Garofalo
 
PPTX
Java_Collections_Framework- array, list, set
FatimaTamboli2
 
DOCX
C# Collection classes
MohitKumar1985
 
PPTX
Java Unit 2 (Part 2)
Dr. SURBHI SAROHA
 
PPTX
Collections in java in detail for easy understanding
thangaraj kesavan
 
PPTX
Python Collections - List, Tuple and Set.
Deeksha Verma
 
PPTX
Collections Training
Ramindu Deshapriya
 
PPTX
Presentation.pptx on java oops concepts jcf
SoumyaSou4
 
PPTX
collections
Yaswanth Babu Gummadivelli
 
PDF
Lecture 4 - Object Interaction and Collections
Syed Afaq Shah MACS CP
 
PPTX
DSA-Lecture04- STL.pptxdjfkdjfkdjfkdjkfjdkfj
mubashirahmed0296
 
PPTX
Javasession7
Rajeev Kumar
 
Collections
niksomer
 
Module 8 : Implementing collections and generics
Prem Kumar Badri
 
Net framework session02
Vivek Singh Chandel
 
9collection in c#
Sireesh K
 
Collections (1)
abdullah619
 
Java Collections Framework - Interfaces, Classes and Algorithms
RajalakshmiS74
 
Introduction To .Net
Soumya Ramachandran
 
Java collections
padmad2291
 
Dewey Classification
Denise Garofalo
 
Java_Collections_Framework- array, list, set
FatimaTamboli2
 
C# Collection classes
MohitKumar1985
 
Java Unit 2 (Part 2)
Dr. SURBHI SAROHA
 
Collections in java in detail for easy understanding
thangaraj kesavan
 
Python Collections - List, Tuple and Set.
Deeksha Verma
 
Collections Training
Ramindu Deshapriya
 
Presentation.pptx on java oops concepts jcf
SoumyaSou4
 
Lecture 4 - Object Interaction and Collections
Syed Afaq Shah MACS CP
 
DSA-Lecture04- STL.pptxdjfkdjfkdjfkdjkfjdkfj
mubashirahmed0296
 
Javasession7
Rajeev Kumar
 
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# Non generics collection
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
 
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# Non generics collection
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
 
Ad

Recently uploaded (20)

PPTX
Cleaning Validation Ppt Pharmaceutical validation
Ms. Ashatai Patil
 
DOCX
pgdei-UNIT -V Neurological Disorders & developmental disabilities
JELLA VISHNU DURGA PRASAD
 
PPTX
TOP 10 AI TOOLS YOU MUST LEARN TO SURVIVE IN 2025 AND ABOVE
digilearnings.com
 
PDF
BÀI TẬP TEST BỔ TRỢ THEO TỪNG CHỦ ĐỀ CỦA TỪNG UNIT KÈM BÀI TẬP NGHE - TIẾNG A...
Nguyen Thanh Tu Collection
 
PDF
The-Invisible-Living-World-Beyond-Our-Naked-Eye chapter 2.pdf/8th science cur...
Sandeep Swamy
 
PPTX
Gupta Art & Architecture Temple and Sculptures.pptx
Virag Sontakke
 
PPTX
I INCLUDED THIS TOPIC IS INTELLIGENCE DEFINITION, MEANING, INDIVIDUAL DIFFERE...
parmarjuli1412
 
PPTX
LDP-2 UNIT 4 Presentation for practical.pptx
abhaypanchal2525
 
PPTX
HEALTH CARE DELIVERY SYSTEM - UNIT 2 - GNM 3RD YEAR.pptx
Priyanshu Anand
 
PPTX
Virus sequence retrieval from NCBI database
yamunaK13
 
PPTX
Applied-Statistics-1.pptx hardiba zalaaa
hardizala899
 
PPTX
Command Palatte in Odoo 18.1 Spreadsheet - Odoo Slides
Celine George
 
PPTX
Applications of matrices In Real Life_20250724_091307_0000.pptx
gehlotkrish03
 
PPTX
CONCEPT OF CHILD CARE. pptx
AneetaSharma15
 
PPTX
Dakar Framework Education For All- 2000(Act)
santoshmohalik1
 
PPTX
Digital Professionalism and Interpersonal Competence
rutvikgediya1
 
PPTX
Introduction to Probability(basic) .pptx
purohitanuj034
 
PDF
Module 2: Public Health History [Tutorial Slides]
JonathanHallett4
 
PPTX
How to Track Skills & Contracts Using Odoo 18 Employee
Celine George
 
PPTX
K-Circle-Weekly-Quiz12121212-May2025.pptx
Pankaj Rodey
 
Cleaning Validation Ppt Pharmaceutical validation
Ms. Ashatai Patil
 
pgdei-UNIT -V Neurological Disorders & developmental disabilities
JELLA VISHNU DURGA PRASAD
 
TOP 10 AI TOOLS YOU MUST LEARN TO SURVIVE IN 2025 AND ABOVE
digilearnings.com
 
BÀI TẬP TEST BỔ TRỢ THEO TỪNG CHỦ ĐỀ CỦA TỪNG UNIT KÈM BÀI TẬP NGHE - TIẾNG A...
Nguyen Thanh Tu Collection
 
The-Invisible-Living-World-Beyond-Our-Naked-Eye chapter 2.pdf/8th science cur...
Sandeep Swamy
 
Gupta Art & Architecture Temple and Sculptures.pptx
Virag Sontakke
 
I INCLUDED THIS TOPIC IS INTELLIGENCE DEFINITION, MEANING, INDIVIDUAL DIFFERE...
parmarjuli1412
 
LDP-2 UNIT 4 Presentation for practical.pptx
abhaypanchal2525
 
HEALTH CARE DELIVERY SYSTEM - UNIT 2 - GNM 3RD YEAR.pptx
Priyanshu Anand
 
Virus sequence retrieval from NCBI database
yamunaK13
 
Applied-Statistics-1.pptx hardiba zalaaa
hardizala899
 
Command Palatte in Odoo 18.1 Spreadsheet - Odoo Slides
Celine George
 
Applications of matrices In Real Life_20250724_091307_0000.pptx
gehlotkrish03
 
CONCEPT OF CHILD CARE. pptx
AneetaSharma15
 
Dakar Framework Education For All- 2000(Act)
santoshmohalik1
 
Digital Professionalism and Interpersonal Competence
rutvikgediya1
 
Introduction to Probability(basic) .pptx
purohitanuj034
 
Module 2: Public Health History [Tutorial Slides]
JonathanHallett4
 
How to Track Skills & Contracts Using Odoo 18 Employee
Celine George
 
K-Circle-Weekly-Quiz12121212-May2025.pptx
Pankaj Rodey
 

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