Hash Tables in C# - How to use and when to use?

  Рет қаралды 25,488

tutorialsEU

tutorialsEU

Күн бұрын

🚀 Master C# and .NET programming EASILY with our best-selling C# Masterclass: bit.ly/47Hk3u7
Hastables in C# - how and when to use?
In this video you will learn all about hastables in C#
When to use hastables and how to use hashtables
In this lesson we will learn about Hashtables and dictionaries
Which are one of the most useful collections in C#. We will see how to define them and how to use them and in which case scenarios we should take advantage of them.
To understand the concept of hashing and tables first think about a real dictionary
Assume we have a German/English Dictionary where every word in German corresponds to only one word in English. So when we try and translate the word 'Auto' in German, which translates to 'Car' in English, we used one word as a keyword to search, and we got the translation as a result
Defining a Hashtable
While we are at it, let's put our last example into action, and let's implement a simple application that will create few objects of type 'Student' and store them into a hashtable using their IDs as keys and the object itself as a value.
Adding Entries to our Hashtable
Now we can define and initialize few objects of our Student class
After we initialize them we will add them to our Hashtable we will use our student Id property as a key and the object it self as the value like we discussed earlier
Fetching Entries from our Hashtable
Now let's try fetching the data from our hashtable
We have a few options
The simplest one if we want to access an element that we already have its key is by accessing it using the hashtable object followed by [] just like an array
Since Hashtables are a non-generic collections they will return an object which before we start working with we have to cast it back to type Student
This is exactly how hashtables and dictionaries in C# behave we use a key to get a value.
#hashtable #hashtables
#generichashtablecsharp
c# hashtable get value by key
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

Пікірлер: 37
IEnumerable 🆚 IEnumerator Interfaces in C#
34:06
tutorialsEU
Рет қаралды 28 М.
Which dictionary to choose in C# and which one is dangerous
11:12
Nick Chapsas
Рет қаралды 101 М.
버블티로 부자 구별하는법4
00:11
진영민yeongmin
Рет қаралды 13 МЛН
А что бы ты сделал? @LimbLossBoss
00:17
История одного вокалиста
Рет қаралды 8 МЛН
Don't look down on anyone#devil  #lilith  #funny  #shorts
00:12
Devil Lilith
Рет қаралды 45 МЛН
📚What is a Dictionary in C#?
27:26
tutorialsEU
Рет қаралды 30 М.
JSON IN C# - Downloading Data and Making Objects From It
24:10
tutorialsEU
Рет қаралды 40 М.
C# Hashsets - Understand them, use them, LOVE them
10:28
tutorialsEU - C#
Рет қаралды 14 М.
Learn Hash Tables in 13 minutes #️⃣
13:26
Bro Code
Рет қаралды 363 М.
Hash Tables and Hash Functions
13:56
Computer Science Lessons
Рет қаралды 1,6 МЛН
The fastest way to iterate a List in C# is NOT what you think
13:42
Nick Chapsas
Рет қаралды 158 М.
What are ASYNC and AWAIT in C#? Asynchronous Programming Tutorial
18:34
Understanding and implementing a Hash Table (in C)
24:54
Jacob Sorber
Рет қаралды 357 М.
버블티로 부자 구별하는법4
00:11
진영민yeongmin
Рет қаралды 13 МЛН