Does the internal .NET HashSet implementation contain a method?

I am writing a test for my library written in C #. And I want to check if two lists are the same if and only if they have the same elements (do not require elements in the same order). I am trying to convert a list to hashset and check if the two hashes are the same. But the result of the execution is not what I expected.

Can someone explain how the hashset method works? Does it match two objects using the getHashCode method of objects or the equals method? Thank!

+3
source share
1 answer

IEqualityComparer < > , HashSet. , EqualityComparer < > . Default. , IEquatable < > Equals GetHashCode .

, , . IEqualityComparer .

+4

Source: https://habr.com/ru/post/1763296/


All Articles