Skip to content

Equals(Object) and GetHashCode() overrides look wrong #11435

Open
@joelf-fractyl

Description

@joelf-fractyl

Type of issue

Typo

Description

In the definition of class Box in the code example, the override of Equals(Object) calls base.Equals(obj) which does not use the custom logic for equality defined in that class. It should call Equals(obj as Box) to use the custom logic. The overridden GetHashCode() should probably also be updated to use custom logic from class Box instead of calling the base class implementation.

Page URL

https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.icollection-1?view=net-9.0#code-try-1

Content source URL

https://github.com/dotnet/dotnet-api-docs/blob/main/xml/System.Collections.Generic/ICollection`1.xml

Document Version Independent Id

d9a82967-6fd7-31b9-6fc9-377daa1a51d4

Platform Id

9cb26e83-4075-c213-0708-b9ded52b04f6

Article author

@dotnet-bot

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions