Skip to content

Inline array Equals unexpected behavior #96943

Closed

Description

Description

Default Equals implementation compares only the first element of inline array.

Reproduction Steps

var a1 = new A();
a1[0]=1;
a1[1]=2;

var a2 = new A();
a2[0] = 1;
a2[1] = 1;


Console.WriteLine(a1.Equals(a2));

[InlineArray(2)]
struct A
{
   public int? P;
}

This code prints true sharplab

Expected behavior

Should compare all values in inline array and print false in this case.

Actual behavior

Compares only the first element.

Regression?

No

Known Workarounds

Override Equals

Configuration

.net 8, Win 10

Other information

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    area-System.Runtimein-prThere is an active PR which will close this issue when it is merged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions