C# Equality and Hashcodes

Поделиться
HTML-код
  • Опубликовано: 29 окт 2024

Комментарии • 38

  • @CodingTutorialsAreGo
    @CodingTutorialsAreGo  3 года назад +2

    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 ruclips.net/channel/UCqWQzlUDdllnLmtgfSgYTCA
    And if you liked it, click the 👍.

  • @tanmaymishra92
    @tanmaymishra92 3 года назад +5

    The answer i was looking for - 7:51 , thank you very much

    • @tore28
      @tore28 Месяц назад

      Sort of like a "stamp" or like a "MD5" hash of a file - it is a unique identifier ignoring that there might be theoretically hash collisions (which MD5 got)

  • @carlscotney3873
    @carlscotney3873 3 года назад +2

    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.

  • @insigpilot
    @insigpilot 2 года назад +2

    Lessons like this will take my skills to the next level. Thanks mate!

  • @wowDepressive
    @wowDepressive Год назад +1

    Excellent! thank you very much. Love your thorough and relevant approach. covers a lot of the subject

  • @davidamour4501
    @davidamour4501 3 года назад +2

    I've watched a lot of tutorials over the years and this is one of the best. Very clear, thorough and easy to follow.

  • @AndrewAndZz
    @AndrewAndZz Год назад +1

    Very clear and great-structured explanation of such an important concept in .NET! Thank you a lot indeed, Jasper! 👏

  • @88spaces
    @88spaces 2 года назад +3

    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.

  • @danixadem
    @danixadem 2 года назад +1

    very comprehensive explanation about the topic. Great work

  • @xavieryang1255
    @xavieryang1255 Год назад +1

    Thank you very much for the tutorial. You made everything crystal clear!

  • @LuciferTheBloody
    @LuciferTheBloody 2 года назад +2

    Wow this was very informative, clear and easy to understand. Especially good actually seeing you do it in code. Thanks!

  • @muriilouwu
    @muriilouwu 3 месяца назад +1

    such a good explanation about hashcodes, thanks!

  • @peternguyen9382
    @peternguyen9382 Год назад +1

    i am lucky to found your channel! thanks for hard working.

  • @corso321
    @corso321 2 года назад +1

    Well explained. I'm impressed.

  • @tiburciolapanak
    @tiburciolapanak 3 года назад +2

    this is how you would know if someone is really an expert

    • @paxvostrum4824
      @paxvostrum4824 3 года назад +3

      also when someone looks like a professor and has books about Lenin (lower left corner)

  • @niranjannt637
    @niranjannt637 2 года назад +1

    Awesome explanation!!! Loved it.

  • @davidbrookoliver
    @davidbrookoliver 2 года назад +1

    Thanks for that man, helped a lot.

  • @erthill2269
    @erthill2269 2 года назад +1

    That was very helpful, thank you!

  • @eslammahfouz
    @eslammahfouz 2 года назад +1

    Great explaination, thanks sir.

  • @theoceandragongaming
    @theoceandragongaming Год назад +1

    What an explanation.

  • @hugodufort3573
    @hugodufort3573 2 года назад +1

    Thanks, that was very clear!

  • @Schnickalodeon
    @Schnickalodeon 3 года назад +1

    I just want to thank you for your content :) you are amazing :)

  • @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...

  • @FatihTurkerFatih
    @FatihTurkerFatih Год назад +1

    Wow ! well done sir

  • @salvatoreamaddio2983
    @salvatoreamaddio2983 2 года назад +1

    My Hero

  • @RiversJ
    @RiversJ Год назад +1

    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.

  • @rishabhmehta2416
    @rishabhmehta2416 2 года назад +1

    Thank you so much

  • @TwinbeeUK
    @TwinbeeUK 2 года назад +1

    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 года назад +1

      Exactly the answer I would have given :)

    • @TwinbeeUK
      @TwinbeeUK 2 года назад +1

      @@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).

  • @finwwwfinwww4669
    @finwwwfinwww4669 2 года назад +1

    You are awesome

  • @bashirmanafikhi
    @bashirmanafikhi 2 года назад +1

    wow ♥