.NET 11 and C# 15 landed on November 10, 2026, and this one is a big deal. Why? Because C# finally has union types. Yes, the feature we've been begging for since roughly forever.

In a recent development, if you're a busy C# dev and just want the short version, grab a coffee β˜•. This is everything you need in about 10 minutes: what changed, what the code looks like, and when you'd actually use it.

Good news: C# 15 is the default language version for net11.0, so you don't have to touch LangVersion. (Related: Tech Report: How to train a fresh language model from s...)

Be honest. How many times have you faked "this value can be A, B, or C" with a base class, the OneOf library, or an object and a pile of casts? Same here.

Here's the old way most of us wrote it:.

Now it's just part of the language:. (Related: How to generate text: using different decoding methods ...)

You can assign any of the case types directly, because they convert to the union automatically:.

According to recent reports, here's the part I love: the compiler checks that your switch handles every case. Add a Fish to the union six months from now, and every switch that forgot about it gets flagged. No more "oops, we never handled that" bugs showing up in production.

This is the pattern I think most of us will use first:.

It has been revealed that no exceptions for control flow. No surprise nulls. Every outcome is right there in the type, and the compiler has your back.

Industry observers note that read it once and you know every way a login can end. That's the whole point.

Reach for it when a method can end in a few different ways: success, not found, validation failed, and so on.

According to recent reports, maybe you like good old class hierarchies, but you still want that "did you handle every case?" check. That's what closed is for:.

A few rules worth knowing so they don't bite you later:.

Industry observers note that so which one do I pick? Here's how I think about it:.

Collection expressions ([1, 2, 3]) are lovely, but there was always one annoying gap: you couldn't pass constructor arguments like a capacity or a comparer. That's fixed now. Just put with(...) as the first element.

Before, you had to fall back to the old style:.

And pre-sizing a list when you already know roughly how big it'll get:.

Tiny feature, but I have a feeling you'll use it every week.

C# 14 gave us extension blocks. C# 15 lets you put indexers inside them:.

It has been revealed that here's a more everyday one. Grab a config value with a fallback, right from the indexer:.

One catch: the receiver (sequence or settings here) has to be a named parameter, because indexers are always instance members.

It has been revealed that ⚠️ A friendly warning: ElementAt on an IEnumerable can walk the whole sequence. Nicer syntax doesn't make it any faster, so don't drop this into a hot loop.

Sources indicate that you know that awkward bool found = false; dance to get out of nested loops? Or the goto you felt slightly guilty about? Here's the "before" we've all written:.

Industry observers note that put the label right on the loop (or switch). Plain break and continue work exactly like they always did. Bonus: the newly introduced IDE0410 analyzer will point out old flag or goto patterns you can clean up.

This one is small but handy. Non-virtual static members with a body now work in interfaces even if you target older runtimes:.

Just keep in mind that default instance implementations, static abstract, and static virtual members still need runtime support.

Industry observers note that C# 15 starts rethinking what unsafe means. Instead of just saying "pointers live here", it becomes a contract that callers have to respect. It's still a preview, so please keep it out of production for now.

If you're curious and want to play with it:.

It has been revealed that if you don't write low-level code, feel free to skip this one. You won't miss much yet.

πŸ“– What's latest in .NET 11 Β· What's new in ASP.NET Core 11.

Honestly, this part matters more than any shiny feature:.

In a recent development, if you only try one thing from this release, make it union types. Here's an easy way to start: find one method in your codebase that returns null or throws when something isn't found, and turn it into a union result. I think you'll feel the difference right away.

According to recent reports, if you're a .NET fan like me, I'd really love to hear from you! Drop a comment and tell me:.

It has been revealed that even a quick "union types, finally!" makes my day. πŸ˜„.

And if this saved you some time, hit the ❀️ and share it with your team. Happy coding, and see you in the comments! πŸ‘‡.

β†’ Read original article