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 6254527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T14:11:41+00:00 2026-05-24T14:11:41+00:00

Using Reflector or DotPeek, the System.Linq.Data.Binary implementation of the equality operator overload looks like

  • 0

Using Reflector or DotPeek, the System.Linq.Data.Binary implementation of the equality operator overload looks like this:

[Serializable, DataContract]
public sealed class Binary : IEquatable<Binary>
{
...
    public static bool operator ==(Binary binary1, Binary binary2)
    {
        return ((binary1 == binary2) || (((binary1 == null) && (binary2 == null)) || (((binary1 != null) && (binary2 != null)) && binary1.EqualsTo(binary2))));
    }

I must be missing something obvious, or there is a mechanism taking place of which I’m unaware (such as implicitly calling object == within the body?). I admit, I rarely if ever need to overload standard operators.

Why does this implementation not result in an infinite recursion (which a simple test shows it doesn’t recurse infinitely)? The first conditional expression is binary1 == binary2, within the implementation of the operator overload that would get called if you used binary1 == binary2 outside the implementation, and I would have thought, inside as well.

  • 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-05-24T14:11:42+00:00Added an answer on May 24, 2026 at 2:11 pm

    I expect this to be a bug in your decompiler. Redgate Reflector had/has the same bug, and I’ve found it in ILSpy too.

    The reason why this is hard to decompile is because it subtly tests the C# overloading rules. The original code was most likely something like (object)obj1==(object)obj2, but this conversion can’t be seen in the IL itself. Casting any reference type to a base type is a no-op as far as the runtime is concerned. It does however get C# to choose the referential equality opcodes instead of calling the overloaded equality operators.

    IMO the correct way to implement this in a decompiler is to always decompile referential equality checks to (object)obj1==(object)obj2 and then optimize out the redundant casts if they don’t affect overload resolution. This approach will fix similar problems with method overloading too.

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

Sidebar

Related Questions

From a brief look using Reflector, it looks like String.Substring() allocates memory for each
I found this piece of code inside System.Web.ISAPIRuntime using Reflector public void DoGCCollect() {
I need to this at runtime. I checked using Reflector and value types line
Using reflector I found the following code in the System.Web.UI.WebControls.Parameter class: internal void UpdateValue(HttpContext
I was using Reflector to look at the implementation of String.Format and had always
I was browsing the types in mscorlib using reflector (like you do...) and came
I'm looking at the implementation of the VolatileRead/VolatileWrite methods (using Reflector), and i'm puzzled
I have a process in a website (Asp.net 3.5 using Linq-to-Sql for data access)
I am using Reflector but I can't find System.ServiceModel.ServiceHost.Dispose(). Where is it?
In looking at System.Linq.Enumerable through Reflector i noticed that default iterator used for Select

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.