All the code in this series is available on GitHub. Clone it, run it, and try breaking it yourself.
georgekobaidze / dotnet11-playground
A lightweight playground repository for experimenting with and testing new features introduced in .NET 11 and C# 15.
.NET 11 & C# 15 Playground
A lightweight playground repository for experimenting with and testing new features introduced in .NET 11 and C# 15.
Use it to explore language changes, try out APIs, and validate ideas in isolation without production constraints. Each feature lives in its own small project, often with a "before" and "after" version so you can see what the new feature actually changes.
What's inside
| Project | Feature | Description |
|---|---|---|
| Unions | Union types | Console examples: the login flow (before and after unions), plus samples for parsing input, a state machine, user commands, and combining types you don't own. |
| UnionsWebApi | Union types | A minimal API that returns a union from a service and maps each outcome to an HTTP response. |
More examples will be added as new features are explored.
Getting started
You'll need the .NET 11 SDK. Then clone the repo and run any example:
dotnet run… Follow me on GitHub for more updates!
Table of Contents
- Floppy Disk Vibes in 2026
- 24 Years Late to the Party
- The Nested Loop Tax
- Wait, C# Already Had Labels?
- Enter C# 15
- Labeled break vs goto
- So... How Do I Feel About It?
- Meet Labeled continue
- Escaping a Loop From Inside a switch
- The Rules of the Game
- Your IDE Already Wants You to Use It
- Wrapping Up
Floppy Disk Vibes in 2026
C# 15 is here, and one of its new features has such an old-school vibe, it could come with a floppy disk.
Yes, I'm talking about labeled break and continue, also known as labeled loops.
Wait, what's a floppy disk?
If you don't know what a floppy disk is, congratulations, you're probably still in your 20s. Here's what they look like:
And yes, those are mine. They still work.
Though I'm not that old. I just stepped into my 30s, which makes me a proud millennial. Old enough to remember floppy disks, young enough that my knees only complain after leg day.
Holding working floppy disks in 2026 feels exactly like using labeled loops in C# 15. Both are technology from another era, both still do their job perfectly, and both make you wonder: "Wait, why does this feel new?"
24 Years Late to the Party
This feature is about 24 years late to the party. C# 1.0 shipped in 2002, and this feels like something that should have been in the box on day one.
Here's why it feels so late. C# was heavily inspired by Java (with a good dose of C++), and Java has had labeled loops since its very first release in 1996. Thirty years ago. In Java, breaking out of a nested loop has always looked like this:
outer: for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { if (i * j == 6) { System.out.println("Found it: " + i + " x " + j); break outer; // exits BOTH loops } } } One label, one break outer;, and you're out of both loops. No flags, no tricks, no drama. Easy.
The Nested Loop Tax
Meanwhile, C# developers spent more than two decades writing this:
bool found = false; for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { if (i * j == 6) { Console.WriteLine($"Found it: {i} x {j}"); found = true; break; // only exits the inner loop... } } if (found) break; // ...so we need a second break for the outer one } If you've written C# for more than a week, you've written this. We all have. It's the nested loop tax.
Wait, C# Already Had Labels?
Here's something even weirder: C# has had labels since day one. They just had exactly one job: being a target for goto.
For anyone who hasn't seen goto in the wild (lucky you), here's how it works in C#:
for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { if (i * j == 6) { Console.WriteLine($"Found it: {i} x {j}"); goto done; // jump straight to the label below } } } done: Console.WriteLine("Out of the loops!"); You put a label in the method (done:), and goto done; teleports execution there. It works, and it solves the nested loop problem, but goto has a reputation... a bad one. A really, really bad one. Don't use it. Just don't.
The problem with goto is that it can jump almost anywhere in the method. The label can be above you, below you, or 200 lines away, so you have to go hunting for it to understand what happens next. Your code can get messy really fast.
Enter C# 15
C# 15 takes those same labels and lets break and continue use them:
outer: for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { if (i * j == 6) { Console.WriteLine($"Found it: {i} x {j}"); break outer; // exits BOTH loops } } } Look familiar? It's almost character-for-character the Java version from earlier.
Labeled break vs goto
The key difference from goto is that the label sits on the loop itself, and break outer; can only target a loop (or switch) that you're currently inside. You can't jump to random places or into the middle of something else. It's controlled, structured, and the intent is obvious just from reading the line: "get me out of the outer loop."
bool flag | goto | Labeled break | |
|---|---|---|---|
| Extra state to track | Yes | No | No |
| Can jump anywhere | No | Almost 😬 | No, only to enclosing loops or switch |
| Intent readable at the jump | Meh | Not really | Yes |
| Gets you side-eye in code review | Sometimes | Always | We'll see... |
So... How Do I Feel About It?
To be honest, I don't know yet.
Part of me thinks it's weird. Labels have always meant "goto lives here, be careful," and that reflex is hard to unlearn.
But another part of me kinda likes it. It makes the code simpler. The flag variable is gone, the second break is gone, and the logic reads exactly the way I'd explain it out loud.
The truth is, I haven't used it enough in real-world code to make up my mind (duh... it's a brand-new feature). So in this article, I'm going to do what I do with every new feature: poke it, push it, and see where it shines and where it starts to smell.
Let's unpack it.
Meet Labeled continue
So far, we've only talked about break. But continue got the same upgrade, and it might be the more useful of the two.
A regular continue skips to the next iteration of the innermost loop. A labeled continue skips to the next iteration of whichever loop you name.
Let's say we're packing orders, and if any item in an order is out of stock, we want to skip the entire order and move on to the next one:
string[][] orders = [ ["Keyboard", "Mouse"], ["Monitor", "OUT_OF_STOCK", "Cable"], ["Headphones"] ]; nextOrder: foreach (string[] order in orders) { Console.WriteLine("New order:"); foreach (string item in order) { if (item == "OUT_OF_STOCK") { Console.WriteLine(" Item missing, skipping this order."); continue nextOrder; // jump to the next ORDER, not the next item } Console.WriteLine($" Packing {item}"); } Console.WriteLine(" Order shipped!"); } Output:
Notice that the second order never prints "Order shipped!". The continue nextOrder; skipped the rest of the outer loop body and went straight to the next order.
Also notice the label name. I could've called it outer, but nextOrder makes continue nextOrder; read like plain English. Name your labels by intent, not by position. Future you will thank you.
How We Did It Before C# 15
Here's the same logic without labeled loops, the way we've been writing it for years:
foreach (string[] order in orders) { Console.WriteLine("New order:"); bool skipOrder = false; foreach (string item in order) { if (item == "OUT_OF_STOCK") { Console.WriteLine(" Item missing, skipping this order."); skipOrder = true; break; // step 1: get out of the inner loop... } Console.WriteLine($" Packing {item}"); } if (skipOrder) continue; // step 2: ...then skip the rest of the outer loop Console.WriteLine(" Order shipped!"); } It works, but look at what it costs:
- An extra variable whose only job is to carry a message from the inner loop to the outer one.
- Two jumps instead of one: a
breakinside, then acontinueoutside. - A hidden trap:
skipOrderhas to be declared inside the outer loop so it resets for every order. Move it above the outerforeach, and after the first skipped order, every order after it gets skipped too. It still compiles, there's no warning, and the output is quietly wrong.
With C# 15, all of that collapses into a single line: continue nextOrder;. That's really what a labeled continue is: a break from the inner loop and a continue on the outer loop, in one statement.
Escaping a Loop From Inside a switch
This one has annoyed C# developers forever. Inside a switch, break belongs to the switch, not the loop around it. So if you want to exit the loop from within a case, a plain break won't help.
Labeled break fixes that:
string[] commands = ["move", "jump", "quit", "move"]; gameLoop: foreach (string command in commands) { switch (command) { case "move": Console.WriteLine("Moving..."); break; // exits the switch only case "jump": Console.WriteLine("Jumping..."); break; // exits the switch only case "quit": Console.WriteLine("Quitting the game."); break gameLoop; // exits the whole loop } } Output:
The last "move" never runs, because break gameLoop; jumped out of both the switch and the foreach.
The Rules of the Game
Labeled jumps are simple, but there are a few rules worth knowing before you start sprinkling labels everywhere.
Rule #1: break can target loops and switch. continue can only target loops.
That makes sense when you think about it. You can exit a switch, but there's no "next iteration" of a switch to continue to. So this won't compile:
mySwitch: switch (value) { case 1: continue mySwitch; // ❌ compile error: continue needs a loop } Rule #2: You can only jump to something you're inside.
Labeled break and continue only work with an enclosing loop or switch. You can't use them to jump sideways into another loop or to some random spot in the method. This is exactly what makes them safer than goto.
Rule #3: Watch out for stacked labels.
This is the sneaky one. C# technically lets you put more than one label in front of a statement:
first: second: for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { if (i * j == 6) break first; // ❌ compile error } } You might expect both labels to point to the for loop, but they don't. Only the label directly in front of the loop (second) labels the loop. first labels the second: for (...) labeled statement, which isn't a loop. So break first; fails to compile, while break second; works just fine.
Is this something you'll run into every day?
No.
Will it confuse someone on your team at 6 PM on a Friday?
Absolutely.
Rule #4: Without a label, nothing changes.
Plain break and continue work exactly as they always did. This feature is purely additive, so none of your existing code changes behavior.
Your IDE Already Wants You to Use It
Here's a fun surprise. .NET 11 comes with a new code style rule, IDE0410 ("Use labeled jump statement"), that looks for the old patterns: bool flags propagating a break outward, goto jumping past nested loops, and goto to an empty label at the end of a loop body. It then suggests replacing them with a labeled break or continue.
It's on by default for C# 15 projects. So if you open an old codebase full of found = true; break; patterns after upgrading, don't be surprised when your IDE lights up like a Christmas tree.
If you're not ready for that, you can turn it off in your .editorconfig:
[*.cs] dotnet_diagnostic.IDE0410.severity = none Wrapping Up
Labeled break and continue aren't flashy. They won't make headlines like union types did. But they fix a small, annoying problem that C# developers have been working around for 24 years.
Quick cheat sheet:
- Use a labeled
breakto exit an outer loop, or a loop from inside aswitch. - Use a labeled
continueto skip to the next iteration of an outer loop. - Name labels by intent (
nextOrder,gameLoop), not position (outer,loop1). - Avoid stacked labels.
- Keep it simple: one label per loop nest is usually plenty.
So, do I like it? I think I do. It's like my floppy disks: retro, a little weird in 2026, but it still does its job perfectly.
All the code from this article is in my .NET 11 playground: dotnet11-playground. Feel free to clone it, break it, and contribute.
What about you? Are you going to use labeled loops, or do they give you goto flashbacks? Let me know in the comments. 👇
Let's stay connected!






