Ad
  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    This is tricky.

    new String will never be interned if not interned explicitly, because it is, well, new-ed. So it's always new in the beginning, you will not get an interned instance by calling new (it can be interned later, but details are not simple). But. C# has the concept of operator overloading (unlike Java), and it overloads the operator == for many value types, including string. That's why str1 == str2 performs value equality check, and not a reference equality check. new String("") == "" will always return true. But. The example you showed does not perform a string equality check. It compares an object with a string, so the overloaded String.operator == does not kick in. The comparison is a reference equality check, and, in this case, it will return true only when checking equality of interned string instances.

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution