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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:57:03+00:00 2026-05-31T17:57:03+00:00

Suppose I define two tuples: Tuple<float, float, float, float> tuple1 = new Tuple<float, float,

  • 0

Suppose I define two tuples:

Tuple<float, float, float, float> tuple1 = new Tuple<float, float, float, float>(1.0f, 2.0f, 3.0f, 4.0f);
Tuple<float, float, float, float> tuple2 = new Tuple<float, float, float, float>(1.0f, 2.0f, 3.0f, 4.0f);

If I try to compare the tuples, I get different results

bool result1 = (tuple1 == tuple2);    // FALSE
bool result2 = tuple1.Equals(tuple2); // TRUE

I would expect for both calls to return true. What exactly is == comparing?

  • 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-31T17:57:04+00:00Added an answer on May 31, 2026 at 5:57 pm

    For Tuple, the == is comparing the object references because it does not overload the == operator. Since the objects are equivalent, but not the same specific instance, Equals() returns true and == returns false.

    Many types do not overload ==, some prefer to keep a distinction between Equals() for equivalence and == for reference equality.

    In addition, relying on == for equivalence can lead to some weirdness:

    public bool AreSame<T>(T first, T second) where T : class
    {
        return first == second;
    }
    

    The code above will always check for reference equality because an unconstrained generic is considered an object at compile time, thus if the method isn’t virtual, you will get object’s version (even if the type, such as string overloads ==).

    Thus this usage of the above code:

    var x = "Hello";
    var y = "H";
    
    // doing concat to avoid string interring
    AreSame(x, y+"ello");
    

    Yes, the strings are equivalent, yes T is string, but the == is bound to object’s == since the generic is unconstrained, thus this will return false even though the same code with explicit string parameters would return true.

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

Sidebar

Related Questions

Suppose I define two classes in a CSS file with the same name, like
Suppose a header file defines a function template. Now suppose two implementation files #include
Suppose I define a union like this: #include <stdio.h> int main() { union u
Suppose I have #define foo in various header files. It may expand to some
Suppose that I define some class: class Pixel { public: Pixel(){ x=0; y=0;}; int
Suppose I have a list of #define s in a header file for an
I understand that we need to create MXML file to define a view. Suppose
Suppose I have two files containing styles, a.css and b.css. I import them into
Suppose I have two queries on a database table. The queries are defined in
Suppose that I have two data types Foo and Bar. Foo has fields x

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.