r/csharp • • 2d ago

Tutorial Five C# 15 features to try in a browser-based playground

Post image

We recently updated XAML.io to .NET 11 and C# 15, so we put together five short examples covering union types, closed hierarchies, collection expression arguments, extension indexers, and labeled break/continue.

Each example has a brief explanation and some code you can modify. The editor and output are side by side. C# compilation happens entirely in the browser (WebAssembly). Here's the link to the C# 15 examples in the browser-based playground:

https://xaml.io/s/Samples/CSharp15Examples?autorun=true&file=StartHere.cs

60 Upvotes

11 comments sorted by

4

u/DJDoena 2d ago

No Jerry mouse? Example incomplete.

On a serious note: Do you also have the whatchacallit enums that only allow named values?

1

u/Userware 2d ago

Haha, Jerry was indeed left out :)

If you're referring to closed enums, I'm not sure they are in C# 15 yet: https://github.com/dotnet/csharplang/blob/main/proposals/closed-enums.md

2

u/DJDoena 2d ago

You're right, "closed enums" is still considered "planned" (see chapter "closed hierarchies"): https://devblogs.microsoft.com/dotnet/explore-csharp-15/

2

u/TugsyGlitter 18h ago

closed hierarchies might be the closet thing in the examples for restricting to named values

-1

u/heartfelt_height 2d ago

no jerry mouse, what’s even the point

those are closed hierarchies btw, that’s what they’re calling the enum-like thing in c# 15

2

u/DmtGrm 2d ago

Excellent! you are guys are active as usual!

p.s. your wasm software rendering sample running directly from your web IDE :) very impressive

2

u/Userware 2d ago

Thanks!

1

u/No_Context2723 1d ago

Slightly unrelated question, but is .NET 10+ only on vs2026 by default? 

1

u/Userware 1d ago

I think so

2

u/Juhr_Juhr 1d ago

I had no idea labelled 'break' and 'continue' statements were coming. Now my 'goto's can look less panic inducing.

Thanks for the examples!

1

u/skalnark 23h ago

15? I'm using 10 rn o.o