ITADN

[Proposal]: Labeled `break` and `continue` Statements

#9875OpenCyrusNajmabadi 创建于 2025-12-14
C
CyrusNajmabadicommented
# Labeled `break` and `continue` Statements * Specification: https://github.com/dotnet/csharplang/blob/main/proposals/labeled-break-continue.md * Discussion: https://github.com/dotnet/csharplang/discussions/9876 ## Summary Allow `break` and `continue` statements to optionally specify a label that identifies which loop or `switch` statement to target, enabling cleaner control flow in nested constructs without requiring `goto` statements. For example: ```c# ```csharp outer: for (int x = 0; x < xMax; x++) { for (int y = 0; y < yMax; y++) { if (ShouldSkipRest(x, y)) continue outer; if (ShouldExitAll(x, y)) break outer; } } `````` ## Design meetings
0 条评论