Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify ReferenceEquals Behavior for Value Types in Docs #44624

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

shethaadit
Copy link
Contributor

@shethaadit shethaadit commented Jan 30, 2025

Summary

This PR updates the documentation to clarify that ReferenceEquals returns false for value types due to boxing, not copying. The previous wording could mislead readers into thinking that copying is the primary reason for the false result.

Changes

  • Updated explanation in the "How to test for reference equality (Identity)" article.
  • Added a [!NOTE] to explicitly state that ReferenceEquals returns false for value types because each argument is independently boxed.

Fixes #41839


Internal previews

📄 File 🔗 Preview link
docs/csharp/programming-guide/statements-expressions-operators/how-to-test-for-reference-equality-identity.md How to test for reference equality (Identity) (C# Programming Guide)

@shethaadit shethaadit requested review from BillWagner and a team as code owners January 30, 2025 18:29
@dotnetrepoman dotnetrepoman bot added this to the January 2025 milestone Jan 30, 2025
@dotnet-policy-service dotnet-policy-service bot added dotnet-csharp/svc fundamentals/subsvc community-contribution Indicates PR is created by someone from the .NET community. labels Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community-contribution Indicates PR is created by someone from the .NET community. dotnet-csharp/svc fundamentals/subsvc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ReferenceEquals always returns false for struct comparison
1 participant