Skip to content

Document labeled break and continue (C# 15)#54999

Draft
BillWagner wants to merge 1 commit into
dotnet:mainfrom
BillWagner:labeled-break-continue
Draft

Document labeled break and continue (C# 15)#54999
BillWagner wants to merge 1 commit into
dotnet:mainfrom
BillWagner:labeled-break-continue

Conversation

@BillWagner

@BillWagner BillWagner commented Jul 22, 2026

Copy link
Copy Markdown
Member

Summary

Documents the C# 15 (.NET 11) labeled break and continue feature. Fixes #54653.

Scope is limited to the C# reference, publishing the speclet, and the What's new in C# 15 article.

Changes

  • Language reference (jump-statements.md): extended the break and continue sections to cover labeled targets, clarified that continue targets loops only (not switch), and added the "only the immediately-nested statement is labeled" nuance. New snippet examples LabeledBreak and LabeledContinue in the jump-statements snippet project.
  • What's new in C# 15 (csharp-15.md): new bullet + "Labeled break and continue" section.
  • Speclet publishing: added the speclet to specification/toc.yml (Feature specifications → Statements) and to docfx.json (build include, title, and description metadata), following the pattern from Add closed hierarchies for C# 15, preview 5 #54128.

Notes for reviewers

  • ⚠️ Draft — syntax not yet verified. The feature bits haven't shipped, so nothing compiles yet. The two new snippet .cs files use the speclet syntax and their // Output: blocks are reasoned by hand. These will be verified against early bits before the PR is marked ready.
  • Speclet source: labeled-break-continue.md.

Internal previews

📄 File 🔗 Preview link
docs/csharp/language-reference/statements/jump-statements.md Jump statements - break, continue, return, and goto
docs/csharp/specification/toc.yml docs/csharp/specification/toc
docs/csharp/whats-new/csharp-15.md What's new in C# 15

Add documentation for the C# 15 labeled `break` and `continue` feature:

- Language reference: extend the `break` and `continue` sections in
  jump-statements.md, with new snippet examples (LabeledBreak,
  LabeledContinue).
- What's new in C# 15: add a "Labeled break and continue" section.
- Publish the feature speclet via the specification TOC and docfx.json
  (build include, title, and description metadata).

The feature bits haven't shipped yet, so snippet output is reasoned from
the speclet and will be verified against early bits.

Fixes dotnet#54653

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: a542e9e6-723c-47d8-95e0-f4c371174bd8
Copilot AI review requested due to automatic review settings July 22, 2026 18:43
@dotnetrepoman dotnetrepoman Bot added this to the July 2026 milestone Jul 22, 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

Documents the C# 15 labeled break and continue feature across the language reference, the C# 15 “What’s new” article, and the published feature specification (speclet).

Changes:

  • Adds a new “Labeled break and continue” section to the C# 15 “What’s new” page.
  • Extends the jump statements reference to explain labeled targets for break and continue, and adds new snippet examples.
  • Publishes the speclet by wiring it into the C# specification TOC and docfx.json proposal metadata.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
docs/csharp/whats-new/csharp-15.md Adds a new section and TOC entry describing labeled break/continue.
docs/csharp/specification/toc.yml Adds the proposal under Feature specifications → Statements.
docs/csharp/language-reference/statements/snippets/jump-statements/ContinueStatement.cs Adds a labeled continue snippet example.
docs/csharp/language-reference/statements/snippets/jump-statements/BreakStatement.cs Adds a labeled break snippet example.
docs/csharp/language-reference/statements/jump-statements.md Updates break/continue documentation and references the new snippets.
docfx.json Includes the new proposal in build inputs and adds title/description metadata.

Comment on lines +45 to +55
outer: for (int day = 0; day < dailyRoutes.Length; day++)
{
Console.WriteLine($"Day {day + 1}:");

foreach (string route in dailyRoutes[day])
{
if (route == "Bridge closed")
{
Console.WriteLine(" Bridge closed; move to the next day.");
continue outer;
}
Comment on lines +69 to +79
outer: for (int aisle = 0; aisle < stockChecks.GetLength(0); aisle++)
{
for (int bay = 0; bay < stockChecks.GetLength(1); bay++)
{
Console.WriteLine($"Checking aisle {aisle}, bay {bay}.");

if (stockChecks[aisle, bay] == "Blocked")
{
Console.WriteLine("Blocked bay found. Stop the inspection.");
break outer;
}
Comment on lines +142 to +158
```csharp
outer: for (int row = 0; row < grid.Height; row++)
{
for (int column = 0; column < grid.Width; column++)
{
if (grid[row, column].IsBlocked)
{
continue outer;
}

if (grid[row, column].IsGoal)
{
break outer;
}
}
}
```
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.

[C# 15-Fundamentals and reference]: Labeled break and continue

2 participants