dotnet / dotnet/dotnet-api-docs
Collections like Lists are cannot be used with HashCode.Combine(collection);
- Dominant language
- C#
- Stars
- 949
- Forks
- 1.7k
- Avg merge
- 3d 27m
- Merged PRs (30d)
- 49
Description
### Type of issue
Missing information
### Description
I spent a good deal of time trying to understand why my Distinct operations were not working for a newly created Type.
It turns out that the **HashCode.Combine(collection);** does not work, it works fine when the instances passed in are not collections, but the documentation doesn't say that clearly.
In my opinion there should be a type check in the method itself as this makes the code very dangerous as only at runtime the issue can be discovered.
I found it just because I was testing most of the equality features around my new type.
I'd be happy to know if I am missing something
### Page URL
https://learn.microsoft.com/en-us/dotnet/api/system.hashcode.combine?view=net-8.0#system-hashcode-combine-1(-0)
### Content source URL
https://github.com/dotnet/dotnet-api-docs/blob/main/xml/System/HashCode.xml
### Document Version Independent Id
4b23ab47-87c7-32b1-a0ca-9c13d5ec93e5
### Article author
@dotnet-bot
Contributor guide
Assessment
This issue has not been assessed yet.