📚What is a Dictionary in C#?

  Рет қаралды 31,409

tutorialsEU

tutorialsEU

Күн бұрын

🚀 Master C# and .NET programming EASILY with our best-selling C# Masterclass: bit.ly/47Hk3u7
In this video, you will learn what is a dictionary in C#?
In this video, you are going to learn about dictionaries
You will need dictionaries if you want to become an awesome C# developer
We are currently updating our Complete C# Masterclass and decided to share some amazing videos here, on my KZbin channel.
Full updates will be available within the next couple of weeks on Udemy, so check out the link above and get your Complete C# Programming Masterclass with a discount.
Previously we talked about Hashtables, in this tutorial we will discuss the Generic version of a hashtable which is a dictionary:
• Hash Tables in C# - Ho...
📍Defining a Dictionary
Similar to a hashtable a dictionary will store it's value in a key-value pair.
We can then use the key to retrieve the value next we will see how to use a dictionary and what special methods it got.
From miscrosoft documentation the dictionary is defined like this: Dictionary (TKey, TValue)
which means we have to specify the types of both our keys and values in the declaration similar to how we define a list List (int) for example but the only difference here is that we need to specify two types.
📍Adding key-value Pairs to a Dictionary
Dictionaries are basically a collection of key-value pair under the hood so we can add new entries in our dictionary by creating a new
Lets Consider the following Class, We will use it to create an employee directory where we will search in this directory using the role name and in return we will get the employee data
To achieve this a dictionary would work just like magic, for our Key we will use the Role which is a string and we will use the Employee type as a value
📍Fetching Data from a Dictionary
There are many ways to get values from a dictionary here we will explore few of them
1. Using Indexer, If we already know the key and we want to get it's value we can access the value of the dictionary just like an array using the dictionary's indexer
2. Using TryGetValue() method, Similar to a hashtable we must be careful when we access a dictionary because if we try accessing a value in the dictionary with a key that does not exists it will throw an error.
3. Using ElementAt(), this method requires an index (int) and it will return the key-value pair at that index we can use a for loop to access all key-value pairs of our Dictionary.
c# add to dictionary
c# initialize dictionary
c# foreach dictionary
c# get value from dictionary
c# dictionary keys
c# dictionary unity
dictionary in c#
c# dictionary containskey
tutorialsEU offers you free video tutorials about programming and development for complete beginners up to experienced programmers.
This includes C#, Unity, Python, Android, Kotlin, Machine Learning, etc.
Stay tuned and subscribe to tutorialsEU: goo.gl/rBFh3x

Пікірлер
@clinton6087
@clinton6087 Жыл бұрын
Currently going thru your c# master class on udemy. You're an awesome instructor. Thanks for all you do.
@pedromiranda5448
@pedromiranda5448 3 жыл бұрын
These new C# videos are very good
@tutorialsEU
@tutorialsEU 3 жыл бұрын
Hi Pedro, we are happy you like it!
@tutorialsEU
@tutorialsEU 2 жыл бұрын
🚀Master C# and .NET programming EASILY with our best-selling C# Masterclass: bit.ly/47Hk3u7
@GazbertUK
@GazbertUK 3 жыл бұрын
Love the picture of the safe with toilet rolls and pasta. After Covid, Brexit and HGV driver shortages, these items are the most precious things in the UK!
@sefatergbashi
@sefatergbashi Жыл бұрын
Thank you so very much. This was indeed well-explained and super clear!
@rufat9113
@rufat9113 2 жыл бұрын
great video! thanks
@gdvdw2256
@gdvdw2256 2 жыл бұрын
This is exactly what I was looking for, thank you 😁
@justmonika6529
@justmonika6529 2 жыл бұрын
love the dark souls references here
@programmingwithjackchew903
@programmingwithjackchew903 3 жыл бұрын
well explained
@evgeniiatotmyanina5534
@evgeniiatotmyanina5534 3 жыл бұрын
Great video!
@daomonkcoder
@daomonkcoder 3 жыл бұрын
herzlichen Dank!
@tutorialsEU
@tutorialsEU 3 жыл бұрын
@dutyman5533
@dutyman5533 3 жыл бұрын
How can I show you picture of my gradel problem?
@shvideo1
@shvideo1 2 жыл бұрын
Great video thank you. A lead developer role as the only developer? :)
@rowlandgoddy-worlu3382
@rowlandgoddy-worlu3382 3 жыл бұрын
nice!!!!!!!
@AliTahreiSh
@AliTahreiSh 2 жыл бұрын
What is the difference between Dictionary and Enum?
@tutorialsEU
@tutorialsEU 2 жыл бұрын
A dictionary is meant for storing data and Enum is more like an option-selection. They are not really comparable :)
@dutyman5533
@dutyman5533 3 жыл бұрын
Hello sir Right now I'm working on with the project that you thought (Android Google Firebase 7 Hours) But I have a problem related to gradel so could you help me to solve it please?
@floris1810
@floris1810 3 жыл бұрын
no
@alexdelarge4120
@alexdelarge4120 2 жыл бұрын
@@floris1810 lol. Duty Man needs to git gud
@StygianStyle
@StygianStyle 2 жыл бұрын
I've been looking at several tutorials about dictionaries, and every one of them is incredibly aggravating. They show how to declare the dictionary, then they go ahead and create a bunch of code for a real-world scenario to use it without explaining in very simple terms how to simply use a key to get a value from an entry in the dictionary, so I always get completely lost at that point.
@aty4282
@aty4282 2 жыл бұрын
Same here..
@kmutech718
@kmutech718 3 жыл бұрын
Hi Denis I have your total udemy course of c#
@pienkow
@pienkow 2 жыл бұрын
I find it poorly explained here, same as hashtables in the linked video. That doesn't really encourage to join your website. I've seen many of your videos, easier topics were well explained but this one (and hashtable topic) dissapointed me :|
@ericocypriani2308
@ericocypriani2308 5 ай бұрын
you know, they usually translate mangas
@PremiereHell
@PremiereHell 2 жыл бұрын
Just wish they were as easy as Python to Implement and use. They seem a bit more work. Yet C# is not python.
@AliTahreiSh
@AliTahreiSh 2 жыл бұрын
You move your mouse curser too much and scroll too much and highlight things for no reason you just make confusion for no reason!!!!!
@ninjaz923
@ninjaz923 3 жыл бұрын
まんが読んでるんかーいw
@dutyman5533
@dutyman5533 3 жыл бұрын
red line org.codehaus.groovy.ast.expr.TupleExpression cannot be cast to org.codehaus.groovy.ast.expr.ArgumentListExpression red line org.codehaus.groovy.ast.expr.TupleExpression cannot be cast to org.codehaus.groovy.ast.expr.ArgumentListExpression red line Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.) Re-download dependencies and sync project (requires network) red line The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem. Stop Gradle build processes (requires restart) red line Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project. red line In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
The weirdest way to loop in C# is also the fastest
12:55
Nick Chapsas
Рет қаралды 254 М.
Hash Tables in C# - How to use and when to use?
16:13
tutorialsEU
Рет қаралды 26 М.
We Attempted The Impossible 😱
00:54
Topper Guild
Рет қаралды 56 МЛН
1% vs 100% #beatbox #tiktok
01:10
BeatboxJCOP
Рет қаралды 67 МЛН
Sigma Kid Mistake #funny #sigma
00:17
CRAZY GREAPA
Рет қаралды 30 МЛН
The Dictionary Data Structure in C# in 10 Minutes or Less
10:20
IAmTimCorey
Рет қаралды 42 М.
What are ASYNC and AWAIT in C#? Asynchronous Programming Tutorial
18:34
IEnumerable 🆚 IEnumerator Interfaces in C#
34:06
tutorialsEU
Рет қаралды 29 М.
How to Manage Fonts in HTML-to-PDF Conversion | IronPDF
4:09
Map and HashMap in Java - Full Tutorial
10:10
Coding with John
Рет қаралды 619 М.
Learn TypeScript Generics In 13 Minutes
12:52
Web Dev Simplified
Рет қаралды 294 М.