What is a HashMap?
Part of the Logic & Flow section of Coddy's C# journey — lesson 46 of 66.
In C#, the equivalent of a HashMap is called a Dictionary. A Dictionary is a collection that stores key-value pairs, allowing you to quickly look up values using their associated keys.
Let's understand the basics:
A Dictionary stores data as key-value pairs
// The syntax is Dictionary<KeyType, ValueType>
Dictionary<string, int> ages = new Dictionary<string, int>();Cheat sheet
A Dictionary stores key-value pairs and allows quick lookups by key:
// Syntax: Dictionary<KeyType, ValueType>
Dictionary<string, int> ages = new Dictionary<string, int>();Try it yourself
This lesson doesn't include a code challenge.
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Logic & Flow
1Multi-dimensional Arrays
2D Arrays BasicsDeclaring and Initializing 2DAccessing 2D Array ElementsNested Loops with 2D ArraysJagged ArraysCommon Matrix OperationsRecap - Multi-dimensional4Flow Control Techniques
Early ReturnsGuard ClausesJump Statements (goto)Break and ContinueFlatten Nested Conditionals7Logical Operators Advanced
Short-Circuit EvaluationConditional Logical OperatorsOperator PrecedenceRecap - Advanced Operators2Advanced Decision Making
Multiple ConditionsComplex Boolean LogicIf vs. Switch ComparisonNested Switch StatementsRecap - Advanced Decisions5Exception Handling
Try-Catch BasicsException TypesMultiple Catch BlocksWorking with FilesFinally BlockUsing vs. Try-FinallyCustom ExceptionsRecap - Error Handling3Loop Enhancements
Loop PerformanceIterating ComplexEach Loop TypeRefactoring LoopsRecap - Optimized Loops6Null Handling
Null Reference BasicsNullable Value TypesNull Checking PatternsDefensive ProgrammingRecap - Null Safety9HashMap Part 1
What is a HashMap?Declare a HashMapCheck If Key ExistsAccessing ValuesModifying DictionariesRecap - HashMap