Slim conditional operator coverage in selection statements - #55613
Draft
BillWagner wants to merge 1 commit into
Draft
Slim conditional operator coverage in selection statements#55613BillWagner wants to merge 1 commit into
BillWagner wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR slims coverage of the conditional operator within the C# selection-statements documentation, in preparation for moving fuller conditional-operator guidance to the Expressions/operators content (dependent on #55469).
Changes:
- Removed the
?:(ternary) example from the selection-statements snippet program. - Reworked the “Conditional operator
?:” section inselection.mdto avoid referencing content that depends on #55469 (and updatedms.date).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| docs/csharp/fundamentals/statements/snippets/selection-statements/Program.cs | Removes the conditional-operator example method and its invocation from the selection-statements snippets. |
| docs/csharp/fundamentals/statements/selection.md | Updates the conditional-operator section content (currently via a placeholder comment) and refreshes the article date. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+58
to
+62
| The conditional operator `?:` chooses one of two values based on a Boolean condition. | ||
|
|
||
| :::code language="csharp" source="./snippets/selection-statements/Program.cs" id="Ternary"::: | ||
|
|
||
| Use `?:` when you assign one of two values, because it keeps the assignment in one place and lets you mark the variable `readonly` or `const`. Prefer an `if` statement when the branches do more than produce a value. For the operator's precedence and associativity rules, see the [conditional operator](../../language-reference/operators/conditional-operator.md) in the language reference. | ||
| <!-- Remove these comment markers after dotnet/docs#55469 merges and this branch is rebased. | ||
| For its syntax, short-circuit behavior, and guidance on choosing it instead of `if`/`else`, see [Conditional operator `?:`](../expressions/operators.md#conditional-operator-). | ||
| --> |
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.
Fixes #55335
This one is small, but dependent on #55469
Internal previews