← Blog

πŸ”· C# 15 Finally Gets It Right: Two Features That Actually Matter

πŸ”· C# 15 Finally Gets It Right: Two Features That Actually Matter
Photo by Markus Spiske from Pexels

I've been writing C# for over a decade. Most version bumps feel like Microsoft checking boxes. C# 15 is different. Two features landed that I'll actually use in production code.

Hi, my name is Tom Smykowski, I'm a staff full-stack engineer. I build and scale SaaS platforms to millions of users, working end-to-end from system architecture to frontend to mobile. On this blog I share practical insights about programming languages and software development.

Let me walk you through what changed and why it matters for your daily work.

Collection Expressions Got Their Missing Piece

Collection expressions were a hit when they shipped. Everyone loved the clean [] syntax. But there was an annoying limitation that kept bugging me.

You couldn't configure the collection during creation.

Building a dictionary with a specific capacity? Nope, back to constructor calls. Creating a sorted set with custom ordering? Same story. The pretty syntax forced you into default behavior.

C# 15 introduces the with(...) clause that changes everything. Now you can specify capacity upfront, use custom comparers, and configure collections at the point of creation.

Discriminated Unions Are Here

This is what I've wanted for years. Proper union types in C#.

If you've touched F#, Rust, or even TypeScript, you understand the concept. A value that holds exactly one option from a fixed set. Not polymorphism. Not marker interfaces. Just "this thing is X or Y or Z, nothing else."

The compiler now enforces exhaustive pattern matching. Delete a case handler? Compiler error. Add a new union member? Every switch expression breaks until you handle it.

Bugs caught during compilation cost nothing. Bugs caught in production cost everything.

This article is free to read

Accept the article license to load the full post. No account or credits required.

Article License (single-reader access) β€” By continuing, you receive a personal, non-transferable, revocable license to access and read this article for your own use.

DO

  • Read and reference the article for personal learning or internal discussion, manually by a human only.
  • Quote short excerpts with attribution and a link to the original article, manually by a human only.
  • Use quotes only when they do not substitute or disclose substantial original parts, manually by a human only.

DON'T

  • Republish, mirror, redistribute, or sell the article in full or in part.
  • Use the article or excerpts as input for AI/ML training, fine-tuning, or datasets.
  • Extract, scrape, summarize, or quote content using bots, scripts, or AI tools.
  • Bypass paywall, licensing, access, or technical protection mechanisms.

Any unlicensed use is prohibited. Breach of these terms automatically terminates this license and may result in access removal and legal enforcement.

Get the newsletter

Posts and notes straight to your inbox

Get new posts and short notes by email β€” no spam, unsubscribe anytime.