Skip to content

[Everyday C#] Fundamentals: Equality comparisons#54849

Merged
BillWagner merged 12 commits into
dotnet:mainfrom
BillWagner:ecsharp-equality-statements
Jul 23, 2026
Merged

[Everyday C#] Fundamentals: Equality comparisons#54849
BillWagner merged 12 commits into
dotnet:mainfrom
BillWagner:ecsharp-equality-statements

Conversation

@BillWagner

@BillWagner BillWagner commented Jul 21, 2026

Copy link
Copy Markdown
Member

Closes #54112

Phase E / PR 14b of the Everyday C# Fundamentals restructuring.

Summary:

  • Adds new article docs/csharp/fundamentals/expressions/equality.md in the new fundamentals/expressions/ folder, added to the TOC under "Expressions and statements".
  • Covers value vs. reference equality, per-type defaults (numeric/enum, structs, records, tuples, classes, interfaces), string/record exceptions, the five related members (==, !=, Equals, GetHashCode, ReferenceEquals), and how to add value equality by hand (with a record-first IMPORTANT callout).
  • Includes a buildable snippet project (snippets/equality/), verified dotnet build 0 warnings/0 errors on net10.0 with dotnet run output matching the article.
  • Deferred: the forward cross-link from operators.md is intentionally deferred to PR 16 and is not included here.

Internal previews

📄 File 🔗 Preview link
docs/csharp/fundamentals/expressions/equality.md C# Equality comparisons
docs/csharp/toc.yml Taken from https://github.com/dotnet/roslyn/wiki/Samples-and-Walkthroughs

BillWagner and others added 7 commits July 21, 2026 11:56
Add fundamentals concept article on object equality for classes,
structs, records, and tuples. Covers value equality vs. reference
equality, Equals/==/ReferenceEquals semantics, IEquatable<T>
implementation pattern, and record compiler-generated equality.
Backed by a net10.0 snippet project (0 warnings, 0 errors).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 5dca83ef-a274-4737-96d5-a311bfe58550
Relocate the Equality fundamentals article and snippets from Type system to the new Expressions folder, and update the TOC and relative links for the new location.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: bc6b7895-3b18-45ff-99de-540618819cb3
Clarify default equality behavior, operator terminology, and manual value equality guidance.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: bc6b7895-3b18-45ff-99de-540618819cb3
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: bc6b7895-3b18-45ff-99de-540618819cb3
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: bc6b7895-3b18-45ff-99de-540618819cb3
Deemphasize the value of IEquatable<T> throughout the article.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: bc6b7895-3b18-45ff-99de-540618819cb3
Copilot AI review requested due to automatic review settings July 21, 2026 19:16
@dotnetrepoman dotnetrepoman Bot added this to the July 2026 milestone Jul 21, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new Everyday C# Fundamentals article that explains equality comparisons across common C# type categories, backed by a buildable snippet project, and wires the article into the C# TOC.

Changes:

  • Adds a new article: fundamentals/expressions/equality.md.
  • Adds a buildable snippet project under fundamentals/expressions/snippets/equality/ used by the article.
  • Updates the C# TOC to link the new article under Expressions and statements.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
docs/csharp/toc.yml Adds a TOC entry for the new equality article.
docs/csharp/fundamentals/expressions/equality.md Introduces the new equality comparisons article and references snippets.
docs/csharp/fundamentals/expressions/snippets/equality/Program.cs Adds runnable examples demonstrating default equality behavior and IEquatable<T>.
docs/csharp/fundamentals/expressions/snippets/equality/equality.csproj Adds a minimal project file to build and run the snippet code.

Comment thread docs/csharp/fundamentals/expressions/equality.md Outdated
BillWagner and others added 4 commits July 22, 2026 11:06
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Run another edit pass on this PR.
This organization of the material works much better.
@BillWagner
BillWagner marked this pull request as ready for review July 22, 2026 18:29
@BillWagner
BillWagner requested a review from a team as a code owner July 22, 2026 18:29
Comment thread docs/csharp/fundamentals/expressions/equality.md Outdated
Comment thread docs/csharp/fundamentals/expressions/equality.md Outdated
Comment thread docs/csharp/fundamentals/expressions/equality.md Outdated

@wadepickett wadepickett left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BillWagner: Approved, great work! See my few very minor suggestions inline that you could take or leave.

Co-authored-by: Wade Pickett <wpickett@microsoft.com>
@BillWagner
BillWagner enabled auto-merge (squash) July 23, 2026 16:00

@wadepickett wadepickett left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BillWagner , re-approved.

@BillWagner
BillWagner merged commit 13736d9 into dotnet:main Jul 23, 2026
10 checks passed
@BillWagner
BillWagner deleted the ecsharp-equality-statements branch July 23, 2026 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Everyday C#] - Phase E, PR 14b. Statements: Equality

3 participants