Add Expressions: operators article (issue #55334) - #55469
Draft
BillWagner wants to merge 6 commits into
Draft
Conversation
Create docs/csharp/fundamentals/expressions/operators.md covering arithmetic, unary, increment/decrement, relational, equality survey, conditional-logical, conditional (?:), simple and compound assignment. - Add operators snippets project (net10.0, nullable, implicit usings) with 9 region-marked examples; 0 warnings, 0 errors - Add operators.md TOC node under Expressions and statements - Add reciprocal link in expressions/index.md - Add reciprocal link in expressions/equality.md - Link excluded operators (shift/bitwise, checked/unchecked) to existing Language Reference pages Closes dotnet#55334 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: f5acfb15-adff-4860-a307-213196efda1c
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new C# Fundamentals article that explains everyday operators (arithmetic, unary, increment/decrement, relational, equality, conditional-logical, conditional ?:, and assignment), along with runnable snippets and navigation updates so the content is discoverable from the Expressions section.
Changes:
- Adds
operators.mdunder Fundamentals → Expressions and links it from related Expressions articles. - Introduces a new snippets project (
snippets/operators) with region-tagged examples used by the article. - Updates the C# TOC to include the new Operators article.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| docs/csharp/toc.yml | Adds the Operators node under Fundamentals → Expressions. |
| docs/csharp/fundamentals/expressions/operators.md | New operators concept article with :::code inclusions and links to reference pages for excluded operator sets. |
| docs/csharp/fundamentals/expressions/snippets/operators/operators.csproj | New .NET snippet project configuration for the operators examples. |
| docs/csharp/fundamentals/expressions/snippets/operators/Program.cs | New runnable sample code containing the operator examples referenced by the article. |
| docs/csharp/fundamentals/expressions/index.md | Adds a cross-link to the new operators article. |
| docs/csharp/fundamentals/expressions/equality.md | Adds a cross-link to the new operators article. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
- Add negative integer division example (-7/2 = -3) to clarify truncation toward zero - Add negative-operand remainder examples (-7%3 = -1, 7%-3 = 1) with sign rule explanation - Explain char relational comparison uses Unicode code point values (tied to grade example) - Update != comment to explicitly say 'true when values are not equal' - Remove invalid commented-out code from EqualityOps snippet; move === example to NOTE callout in article prose as fenced code block - Remove nested conditional example and related prose from ConditionalOp section - Add Console.WriteLine after each compound assignment step (hp progression: 100 -> 120 -> 110 -> 220 -> 73 -> 3) - Rename 'Operators not covered here' to 'Other C# operators'; expand bullets with concise definitions - Add displayName to toc.yml entry for operators.md with all covered operators Copilot-Session: f5acfb15-adff-4860-a307-213196efda1c Co-Authored-By: Copilot <223556219+Copilot@users.noreply.github.com>
Co-Authored-By: Copilot <223556219+Copilot@users.noreply.github.com>
…otnet#55334) Retire the three Programming Guide equality articles and preserve their unique content in docs/csharp/fundamentals/expressions/equality.md: - equality-comparisons.md - how-to-test-for-reference-equality-identity.md - how-to-define-value-equality-for-a-type.md Content migrated into equality.md: - Equivalence contract (5 rules: reflexive, symmetric, transitive, consistent, null behavior) added to the manual-implementation section. - New section: 'Records with reference-type members' — explains that synthesized record equality uses each member's own equality semantics, so List<T>/array members compare by reference; shows custom IEquatable override with SequenceEqual as the recommended fix. - New section: 'Polymorphic equality in unsealed class hierarchies' — explains the compile-time dispatch hazard with IEquatable<T>, the GetType() guard and virtual Equals pattern for correct unsealed-class equality, and notes that sealed classes and records avoid the problem. Snippet additions to snippets/equality/Program.cs: - RecordWithCollectionProblem / RecordWithCollectionFixed regions - PlaylistFixedDefinition type (custom IEquatable record) - PolymorphicEqualityDefinition (Shape/Circle hierarchy with GetType() guard) - PolymorphicEqualityUsage region Intentionally omitted: string-interning note (per Bill's explicit decision). Retirement wiring: - 3 redirects added to .openpublishing.redirection.csharp.json - TOC entries and empty parent node removed from toc.yml - All 5 inbound links updated: objects.md, how-to/index.md, overloaded-operator-errors.md, record-declaration-errors.md, equality-operators.md - Orphaned snippet projects deleted Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: f5acfb15-adff-4860-a307-213196efda1c
Co-Authored-By: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Create docs/csharp/fundamentals/expressions/operators.md covering arithmetic, unary, increment/decrement, relational, equality survey, conditional-logical, conditional (?:), simple and compound assignment.
Fixes #55334
Internal previews
Toggle expand/collapse