C# Equality and Hashcodes

  Рет қаралды 7,762

Coding Tutorials

Coding Tutorials

3 жыл бұрын

Coding Tutorial: C# offers lots of different ways to determine if two objects are equal. Here we discuss the whole range.
Source code available at: github.com/JasperKent/Equalit...

Пікірлер: 35
@CodingTutorialsAreGo
@CodingTutorialsAreGo 3 жыл бұрын
Any more of these fundamentals you'd like to know? Just ask. Source code at: github.com/JasperKent/Equality-And-Hashcodes Don't forget to subscribe at kzfaq.info/love/qWQzlUDdllnLmtgfSgYTCA And if you liked it, click the 👍.
@tanmaymishra92
@tanmaymishra92 2 жыл бұрын
The answer i was looking for - 7:51 , thank you very much
@peternguyen9382
@peternguyen9382 Жыл бұрын
i am lucky to found your channel! thanks for hard working.
@theoceandragongaming
@theoceandragongaming 8 ай бұрын
What an explanation.
@carlscotney3873
@carlscotney3873 3 жыл бұрын
Just encountered this channel in a recommendation and I haven't looked back since. I've been deep in learning C#/Dotnet for about 18 months now and you seem to have explained so simply almost every little 'hmmm?' moment I've had in the optimal level of detail! Great channel. Thank you so much for taking the time to produce this content.
@davidamour4501
@davidamour4501 3 жыл бұрын
I've watched a lot of tutorials over the years and this is one of the best. Very clear, thorough and easy to follow.
@CodingTutorialsAreGo
@CodingTutorialsAreGo 3 жыл бұрын
Many thanks.
@insigpilot
@insigpilot 2 жыл бұрын
Lessons like this will take my skills to the next level. Thanks mate!
@eslammahfouz
@eslammahfouz Жыл бұрын
Great explaination, thanks sir.
@88spaces
@88spaces 2 жыл бұрын
I've been looking for a video like this for a while that explains why you need to coordinate Equals and GetHashCode. I'm glad I found yours because it explains it perfectly. Thank you. BTW, Amazon quizzes you about hashes until you're hashed out so this is a good primer for their technical interview.
@AndrewAndZz
@AndrewAndZz Жыл бұрын
Very clear and great-structured explanation of such an important concept in .NET! Thank you a lot indeed, Jasper! 👏
@erthill2269
@erthill2269 Жыл бұрын
That was very helpful, thank you!
@LuciferTheBloody
@LuciferTheBloody 2 жыл бұрын
Wow this was very informative, clear and easy to understand. Especially good actually seeing you do it in code. Thanks!
@wowDepressive
@wowDepressive Жыл бұрын
Excellent! thank you very much. Love your thorough and relevant approach. covers a lot of the subject
@hugodufort3573
@hugodufort3573 Жыл бұрын
Thanks, that was very clear!
@danixadem
@danixadem 2 жыл бұрын
very comprehensive explanation about the topic. Great work
@FatihTurkerFatih
@FatihTurkerFatih Жыл бұрын
Wow ! well done sir
@salvatoreamaddio2983
@salvatoreamaddio2983 Жыл бұрын
My Hero
@davioliveira-yj7qv
@davioliveira-yj7qv 2 жыл бұрын
Thanks for that man, helped a lot.
@xavieryang1255
@xavieryang1255 Жыл бұрын
Thank you very much for the tutorial. You made everything crystal clear!
@niranjannt637
@niranjannt637 2 жыл бұрын
Awesome explanation!!! Loved it.
@finwwwfinwww4669
@finwwwfinwww4669 2 жыл бұрын
You are awesome
@tiburciolapanak
@tiburciolapanak 2 жыл бұрын
this is how you would know if someone is really an expert
@paxvostrum4824
@paxvostrum4824 2 жыл бұрын
also when someone looks like a professor and has books about Lenin (lower left corner)
@corso321
@corso321 2 жыл бұрын
Well explained. I'm impressed.
@rishabhmehta2416
@rishabhmehta2416 2 жыл бұрын
Thank you so much
@bashirmanafikhi
@bashirmanafikhi 2 жыл бұрын
wow ♥
@Schnickalodeon
@Schnickalodeon 3 жыл бұрын
I just want to thank you for your content :) you are amazing :)
@CodingTutorialsAreGo
@CodingTutorialsAreGo 3 жыл бұрын
Cheers!
@IBITZEE
@IBITZEE 3 жыл бұрын
very interesting the information you are showing... not so easy to find it so complete in other channels... but please... declare the variables with "var v = new " to unclutter the code you are showing...
@RiversJ
@RiversJ Жыл бұрын
Eh? If the x and y swapped produces the same hashcode then it could change behaviour if you're using hashsets to check if you already have something added to a list for example without using list.contains.
@CodingTutorialsAreGo
@CodingTutorialsAreGo Жыл бұрын
No, because a matching hash only give a higher probability of equality. Whenever hashes match, it should always be confirmed by an exact equality check. That said, a hashing algorithm that produces different results when the values are swapped would be better. Use HashCode.Combine.
@TwinbeeUK
@TwinbeeUK 2 жыл бұрын
Excellent tutorial! A shame C# doesn't easily allow you to use long (rather than int) hash codes by default as that's far less likely to have clashes between objects. Btw, at 23:45 you create a string and get different hash codes on successive runs. However at 11:40, the two strings you created always produced the same hash code, even on following runs. What gives? EDIT: Ah, to answer my own question, the version where the string produces a different hash code on different runs is due to it being under .NET Core instead of .NET Framework (the latter always produces the same hash code). They both work a bit differently it would seem!
@CodingTutorialsAreGo
@CodingTutorialsAreGo 2 жыл бұрын
Exactly the answer I would have given :)
@TwinbeeUK
@TwinbeeUK 2 жыл бұрын
@@CodingTutorialsAreGo Doing some research, it appears the reason for Microsoft's change in .NET Core is due to help security (hackers can potentially exploit the code if they know the hashing algorithm with .NET Framework).
C# Value Types and Reference Types
32:49
Coding Tutorials
Рет қаралды 4,7 М.
Stackalloc and Spans
30:17
Coding Tutorials
Рет қаралды 9 М.
Khó thế mà cũng làm được || How did the police do that? #shorts
01:00
Luck Decides My Future Again 🍀🍀🍀 #katebrush #shorts
00:19
Kate Brush
Рет қаралды 8 МЛН
Sigma Girl Past #funny #sigma #viral
00:20
CRAZY GREAPA
Рет қаралды 29 МЛН
Must-have gadget for every toilet! 🤩 #gadget
00:27
GiGaZoom
Рет қаралды 11 МЛН
C# 12 Collection Expressions and the Spread Operator
25:27
Coding Tutorials
Рет қаралды 1,7 М.
ASP.NET Core Dependency Injection
23:37
Coding Tutorials
Рет қаралды 7 М.
C# Covariance
17:27
Coding Tutorials
Рет қаралды 7 М.
Here Is When HashSet & Dictionary Call GetHashCode and Equals
7:32
Zoran Horvat
Рет қаралды 1,2 М.
.NET Boxing (And Unboxing)
15:19
Coding Tutorials
Рет қаралды 1,6 М.
.NET Core - Dependency Injection Lifecycles
13:50
Coding Tutorials
Рет қаралды 4,3 М.
10 C# Libraries To Save You Time And Energy
33:59
IAmTimCorey
Рет қаралды 204 М.
Implementing IEnumerable
17:35
Coding Tutorials
Рет қаралды 10 М.
The Dangers of Equality in C# - Don't Make This Common Mistakes
35:04
Lid hologram 3d
0:32
LEDG
Рет қаралды 10 МЛН
Урна с айфонами!
0:30
По ту сторону Гугла
Рет қаралды 8 МЛН
YOTAPHONE 2 - СПУСТЯ 10 ЛЕТ
15:13
ЗЕ МАККЕРС
Рет қаралды 149 М.