Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8951037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:34:23+00:00 2026-06-15T13:34:23+00:00

I know the importance of overriding GetHashCode when implementing custom equality checks – for

  • 0

I know the importance of overriding GetHashCode when implementing custom equality checks – for which I have implemented IEquality<T> interface, and also the difference between generic and non-generic Equals as discussed here. Now is there a point to override Equals(object t)? Wouldn’t everything come under generic Equals(T t)?

public override int GetHashCode() //required for hashsets and dictionaries
{
    return Id;
}

public bool Equals(T other) //IEquatable<T> here
{
    return Id == other.Id;
}

public override bool Equals(object obj) //required??
{
    return Equals(obj as T);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T13:34:23+00:00Added an answer on June 15, 2026 at 1:34 pm

    From msdn:

    If you implement IEquatable, you should also override the base
    class implementations of Object.Equals(Object) and GetHashCode so that
    their behavior is consistent with that of the IEquatable.Equals
    method. If you do override Object.Equals(Object), your overridden
    implementation is also called in calls to the static
    Equals(System.Object, System.Object) method on your class. In
    addition, you should overload the op_Equality and op_Inequality
    operators. This ensures that all tests for equality return consistent
    results.

    I could have done a better google search too. Here’s a good article on msdn blogs by JaredPar on the subject.

    In short, overriding Equals(object obj):

    Needed for the static Equals(object obj1, object obj2) method on object class, or for Contains(object item) on ArrayList instance etc..

    Accepting this since the link is more thorough on the subject. Thanks to Oded too..

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know, I have to set the AudioSession to the 'playback' category, which allows
The title is the question. I am curious to know about the importance of
As you know StringFormat is of great importance for data representation in WPF. My
Is it really important to know algorithms to build mobile applications? I have strong
I know this question is not really important.. however I've been wondering: Which of
I know the importance of Browser styles-sheet and author style-sheet. but what is the
I'm looking for recommendations on best practices when implementing equality in a domain model.
Please bear with me -- I know this is complex. I have a table
I am using Ruby on Rails 3 and I would know in which case
Lets say I have a plugin's CSS which loads later as my style.css /*style.css*/

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.