SlideShare a Scribd company logo
C# Dictionary Hash Table and sets
Agenda
What is C# Dictionaries?
Methods in C# Dictionaries
What is C# Hash-table?
Properties of C# Hash-table
Methods in C# Hash-table
C# Hash-set
Implementation
What are C# Dictionaries?
What are C# Dictionaries?
A generic namespace is a class that can include any
type of data in the form of keys and values.
Dictionary is a class defined in the System.Collections
package.
The Dictionary class in C# is a generic collection of key-
value pairs.
Each key in the collection must be unique.
Syntax:
Dictionary<string, string> Dict = new Dictionary<string, string>();
Methods in Dictionaries
Remove element:
Dict.Remove(“Compact");
Add element:
Dict.Add(“Compact", 21);
Methods in C# Dictionaries
In C#, A dictionary can provide methods like:
Find element:
if (!Dict.ContainsKey(“Compact")) {
Dict[“Compact"] = 20;
}
Replace element:
Dict[“Compact"] = 8;
What are C# Hash-tables?
What are Hash-tables?
KEY VALUE
1 11
2 22
3 33
4 44
Each DictionaryEntry object in the collection has
two properties: a key and a value.
A Hash-Table can't have duplicate entries because
it's immutable.
In C#, a Hash-table stores (Keys, Values) pairs,
where Keys can locate the storage.
The table's values can only be accessed by
defining key object.
Syntax:
Hashtable HT = new Hashtable();
Properties of C# Hash-table
Properties of C# Hash-table
Comparer: Returns or sets the IComparer to be
used.
KEY VALUE
1 11
2 22
3 33
4 44
Count: Gets the number of key/value pairs
contained in the hash table.
IsReadOnly: Returns a value indicating if the hash
table is a read-only hash table.
Item: Returns or sets the value corresponding to
the provided Key.
Keys: Returns an ICollection holding the hash
table's keys.
Values: Returns an ICollection holding the hash
table's values.
Methods in C# Hash-table
Methods in C# Hash-table
Various methods in a hash table are:
Add: Inserts an element in the hash table with the
provided key and value.
KEY VALUE
1 11
2 22
3 33
4 44
Clear: Clears the hash table of all its elements.
ContainsKey: Indicates whether or not the hash table
contains the supplied key.
ContainsValue: Indicates whether or not the hash
table contains the specified value.
C# Hash-sets
C# Hash-sets
Sets in C# are called HashSet.
HashSet in C# makes sure there aren't any duplicate
strings or elements in an array.
Value ‘John’ ‘Mary’ ‘Eddie’ ‘Tony’ ‘Snow’ ‘Ray’
Syntax:
var h = new HashSet<string>(arr1);
Implementation
C# Dictionary Hash Table and sets

More Related Content

PPT
C# Basics
PPT
C#.NET
PPT
C++ Programming Course
PPT
Class 5 - PHP Strings
PPTX
Introduction to Java -unit-1
PPTX
Angular Components.pptx
PPTX
PPT
Method overriding
C# Basics
C#.NET
C++ Programming Course
Class 5 - PHP Strings
Introduction to Java -unit-1
Angular Components.pptx
Method overriding

What's hot (20)

PPTX
INLINE FUNCTION IN C++
PPTX
Introduction To C#
PPT
Literals,variables,datatype in C#
PPTX
Java - Collections framework
PPT
DOT Net overview
PPT
C# basics
PPTX
.NET and C# Introduction
PDF
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
PPT
Operator Overloading
PPTX
JAVA-PPT'S.pptx
PDF
Unit Testing in Angular
PPTX
Advance Java Topics (J2EE)
PDF
Java collections
PPTX
Object Oriented Programming with C#
PPTX
Classes and Objects in C#
PPSX
Collections - Lists, Sets
PPTX
.Net Core
PPTX
Abstraction in java.pptx
INLINE FUNCTION IN C++
Introduction To C#
Literals,variables,datatype in C#
Java - Collections framework
DOT Net overview
C# basics
.NET and C# Introduction
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Operator Overloading
JAVA-PPT'S.pptx
Unit Testing in Angular
Advance Java Topics (J2EE)
Java collections
Object Oriented Programming with C#
Classes and Objects in C#
Collections - Lists, Sets
.Net Core
Abstraction in java.pptx
Ad

Similar to C# Dictionary Hash Table and sets (20)

PDF
Dictionary and sets-converted
PPTX
18. Dictionaries, Hash-Tables and Set
PDF
Dictionary e book
PPT
Generics Collections
PPT
Generics collections
PDF
data structure chapter hashing slides for data structures learning
PPTX
Hash tables
PPT
Data Structure In C#
PPT
Chapter 10: hashing data structure
PPTX
Data Structures and Agorithm: DS 24 Hash Tables.pptx
PPTX
COLLECTIONS.pptx
PDF
hash_tables
PPTX
hashing in data strutures advanced in languae java
PDF
Hash pre
PPTX
Hash table in data structure and algorithm
PDF
Hashing CollisionDetection in Data Structures
PDF
03.01 hash tables
PPTX
.net F# mutable dictionay
PPTX
Hashing and Collision Advanced data structure and algorithm
Dictionary and sets-converted
18. Dictionaries, Hash-Tables and Set
Dictionary e book
Generics Collections
Generics collections
data structure chapter hashing slides for data structures learning
Hash tables
Data Structure In C#
Chapter 10: hashing data structure
Data Structures and Agorithm: DS 24 Hash Tables.pptx
COLLECTIONS.pptx
hash_tables
hashing in data strutures advanced in languae java
Hash pre
Hash table in data structure and algorithm
Hashing CollisionDetection in Data Structures
03.01 hash tables
.net F# mutable dictionay
Hashing and Collision Advanced data structure and algorithm
Ad

More from Simplilearn (20)

PPTX
Top 50 Scrum Master Interview Questions | Scrum Master Interview Questions & ...
PPTX
Bagging Vs Boosting In Machine Learning | Ensemble Learning In Machine Learni...
PPTX
Future Of Social Media | Social Media Trends and Strategies 2025 | Instagram ...
PPTX
SQL Query Optimization | SQL Query Optimization Techniques | SQL Basics | SQL...
PPTX
SQL INterview Questions .pTop 45 SQL Interview Questions And Answers In 2025 ...
PPTX
How To Start Influencer Marketing Business | Influencer Marketing For Beginne...
PPTX
Cyber Security Roadmap 2025 | How To Become Cyber Security Engineer In 2025 |...
PPTX
How To Become An AI And ML Engineer In 2025 | AI Engineer Roadmap | AI ML Car...
PPTX
What Is GitHub Copilot? | How To Use GitHub Copilot? | How does GitHub Copilo...
PPTX
Top 10 Data Analyst Certification For 2025 | Best Data Analyst Certification ...
PPTX
Complete Data Science Roadmap For 2025 | Data Scientist Roadmap For Beginners...
PPTX
Top 7 High Paying AI Certifications Courses For 2025 | Best AI Certifications...
PPTX
Data Cleaning In Data Mining | Step by Step Data Cleaning Process | Data Clea...
PPTX
Top 10 Data Analyst Projects For 2025 | Data Analyst Projects | Data Analysis...
PPTX
AI Engineer Roadmap 2025 | AI Engineer Roadmap For Beginners | AI Engineer Ca...
PPTX
Machine Learning Roadmap 2025 | Machine Learning Engineer Roadmap For Beginne...
PPTX
Kotter's 8-Step Change Model Explained | Kotter's Change Management Model | S...
PPTX
Gen AI Engineer Roadmap For 2025 | How To Become Gen AI Engineer In 2025 | Si...
PPTX
Top 10 Data Analyst Certification For 2025 | Best Data Analyst Certification ...
PPTX
Complete Data Science Roadmap For 2025 | Data Scientist Roadmap For Beginners...
Top 50 Scrum Master Interview Questions | Scrum Master Interview Questions & ...
Bagging Vs Boosting In Machine Learning | Ensemble Learning In Machine Learni...
Future Of Social Media | Social Media Trends and Strategies 2025 | Instagram ...
SQL Query Optimization | SQL Query Optimization Techniques | SQL Basics | SQL...
SQL INterview Questions .pTop 45 SQL Interview Questions And Answers In 2025 ...
How To Start Influencer Marketing Business | Influencer Marketing For Beginne...
Cyber Security Roadmap 2025 | How To Become Cyber Security Engineer In 2025 |...
How To Become An AI And ML Engineer In 2025 | AI Engineer Roadmap | AI ML Car...
What Is GitHub Copilot? | How To Use GitHub Copilot? | How does GitHub Copilo...
Top 10 Data Analyst Certification For 2025 | Best Data Analyst Certification ...
Complete Data Science Roadmap For 2025 | Data Scientist Roadmap For Beginners...
Top 7 High Paying AI Certifications Courses For 2025 | Best AI Certifications...
Data Cleaning In Data Mining | Step by Step Data Cleaning Process | Data Clea...
Top 10 Data Analyst Projects For 2025 | Data Analyst Projects | Data Analysis...
AI Engineer Roadmap 2025 | AI Engineer Roadmap For Beginners | AI Engineer Ca...
Machine Learning Roadmap 2025 | Machine Learning Engineer Roadmap For Beginne...
Kotter's 8-Step Change Model Explained | Kotter's Change Management Model | S...
Gen AI Engineer Roadmap For 2025 | How To Become Gen AI Engineer In 2025 | Si...
Top 10 Data Analyst Certification For 2025 | Best Data Analyst Certification ...
Complete Data Science Roadmap For 2025 | Data Scientist Roadmap For Beginners...

Recently uploaded (20)

PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
RMMM.pdf make it easy to upload and study
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Complications of Minimal Access Surgery at WLH
PDF
Pre independence Education in Inndia.pdf
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
Business Ethics Teaching Materials for college
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
VCE English Exam - Section C Student Revision Booklet
Microbial disease of the cardiovascular and lymphatic systems
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Module 4: Burden of Disease Tutorial Slides S2 2025
RMMM.pdf make it easy to upload and study
Microbial diseases, their pathogenesis and prophylaxis
O7-L3 Supply Chain Operations - ICLT Program
Complications of Minimal Access Surgery at WLH
Pre independence Education in Inndia.pdf
Anesthesia in Laparoscopic Surgery in India
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
Final Presentation General Medicine 03-08-2024.pptx
PPH.pptx obstetrics and gynecology in nursing
Business Ethics Teaching Materials for college
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
FourierSeries-QuestionsWithAnswers(Part-A).pdf

C# Dictionary Hash Table and sets

  • 3. What is C# Dictionaries? Methods in C# Dictionaries What is C# Hash-table? Properties of C# Hash-table Methods in C# Hash-table C# Hash-set Implementation
  • 4. What are C# Dictionaries?
  • 5. What are C# Dictionaries? A generic namespace is a class that can include any type of data in the form of keys and values. Dictionary is a class defined in the System.Collections package. The Dictionary class in C# is a generic collection of key- value pairs. Each key in the collection must be unique. Syntax: Dictionary<string, string> Dict = new Dictionary<string, string>();
  • 7. Remove element: Dict.Remove(“Compact"); Add element: Dict.Add(“Compact", 21); Methods in C# Dictionaries In C#, A dictionary can provide methods like: Find element: if (!Dict.ContainsKey(“Compact")) { Dict[“Compact"] = 20; } Replace element: Dict[“Compact"] = 8;
  • 8. What are C# Hash-tables?
  • 9. What are Hash-tables? KEY VALUE 1 11 2 22 3 33 4 44 Each DictionaryEntry object in the collection has two properties: a key and a value. A Hash-Table can't have duplicate entries because it's immutable. In C#, a Hash-table stores (Keys, Values) pairs, where Keys can locate the storage. The table's values can only be accessed by defining key object. Syntax: Hashtable HT = new Hashtable();
  • 10. Properties of C# Hash-table
  • 11. Properties of C# Hash-table Comparer: Returns or sets the IComparer to be used. KEY VALUE 1 11 2 22 3 33 4 44 Count: Gets the number of key/value pairs contained in the hash table. IsReadOnly: Returns a value indicating if the hash table is a read-only hash table. Item: Returns or sets the value corresponding to the provided Key. Keys: Returns an ICollection holding the hash table's keys. Values: Returns an ICollection holding the hash table's values.
  • 12. Methods in C# Hash-table
  • 13. Methods in C# Hash-table Various methods in a hash table are: Add: Inserts an element in the hash table with the provided key and value. KEY VALUE 1 11 2 22 3 33 4 44 Clear: Clears the hash table of all its elements. ContainsKey: Indicates whether or not the hash table contains the supplied key. ContainsValue: Indicates whether or not the hash table contains the specified value.
  • 15. C# Hash-sets Sets in C# are called HashSet. HashSet in C# makes sure there aren't any duplicate strings or elements in an array. Value ‘John’ ‘Mary’ ‘Eddie’ ‘Tony’ ‘Snow’ ‘Ray’ Syntax: var h = new HashSet<string>(arr1);