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

  • Home
  • SEARCH
  • 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 8360601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:30:35+00:00 2026-06-09T11:30:35+00:00

If object.ReferenceEquals returns true, should instance.Equals always return true? Would you think its unexpected

  • 0

If object.ReferenceEquals returns true, should instance.Equals always return true?

Would you think its unexpected behaviour where the output below was pass/fail?

Assert.True(object.ReferenceEquals(obj,obj));
Assert.True(obj.Equals(obj));

Personally I think its strange, and cant really think of a good reason, where an instance should not be equal to itself.

  • 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-09T11:30:37+00:00Added an answer on June 9, 2026 at 11:30 am

    There are two ways to answer your question.

    • It’s unexpected behavior, yes. A properly-designed class should always return true from .Equals if it returns true from .ReferenceEquals. That’s codified in MSDN’s Design Guidelines for Developing Class Libraries, Implementing the Equals Method article:

      Follow the contract defined on the Object.Equals Method as follows:
           x.Equals(x) returns true.

    • But that requirement is not enforced by the language or runtime. The designer of the class in question is perfectly free to define Equals as { return false; }. Perverse, but possible.

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

Sidebar

Related Questions

What decision should I take about Equals(), ReferenceEquals(), and == from the following results?
Is the Is VB.NET keyword the same as Object.ReferenceEquals?
Object slicing is some thing that object looses some of its attributes or functions
Object reference not set to an instance of an object. using System; using System.Collections.Generic;
The second ReferenceEquals call returns false. Why isn't the string in s4 interned? (I
I have read that when you override Equals on an class/object you need to
How can I generate a hash code for an object based on its identity.
Would some kind person help me sort out the output of .Net Reflector v6.5
Object.preventExtensions and Object.seal prevent unknown properties from being added to an object, but those
object[] objs = new object[]{one,two,three}; Are the strings stored in the array as references

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.