Skip to content

Slim conditional operator coverage in selection statements - #55613

Draft
BillWagner wants to merge 1 commit into
dotnet:mainfrom
BillWagner:conditional-or-ternary
Draft

Slim conditional operator coverage in selection statements#55613
BillWagner wants to merge 1 commit into
dotnet:mainfrom
BillWagner:conditional-or-ternary

Conversation

@BillWagner

@BillWagner BillWagner commented Aug 20, 2026

Copy link
Copy Markdown
Member

)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings August 20, 2026 14:22
@dotnetrepoman dotnetrepoman Bot added this to the August 2026 milestone Aug 20, 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

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 in selection.md to avoid referencing content that depends on #55469 (and updated ms.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-).
-->
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#: Slim conditional-operator coverage in Selection statements

2 participants