Black Friday Deals For Authors Are On Now!

Leanpub Header

Skip to main content

Keeping Up with C#

From C# 5 to C# 15: A Thematic Journey Through Language Evolution

Keeping Up with C#
This book is 100% completeLast updated on 2026-11-29

Is this still the language you learned? Ninety-three features shipped between C# 5 and C# 15. This book groups them into nine themes, shows how they compose into eight patterns the modern .NET ecosystem is built on, and adds C# 15’s union types and closed hierarchies, where the compiler proves every case is handled. 11 chapters. 5 runnable companion projects. .NET 11 and C# 15.

Minimum price

Free!

$1.99

You pay

Author earns

$
PDF
Discussion Forum
About

About

About the Book

Records, pattern matching, nullable reference types, Span<T>, source generators, generic math, the field keyword, extension members, and now union types. Ninety-three features have shipped between C# 5 and C# 15, and most developers have picked up a handful along the way. The rest show up in code review, in library source, in a colleague’s pull request, and you’re left wondering whether the language you learned is still the one you’re writing.

Keeping Up with C#, Second Edition is the tour that answers that question. It doesn’t walk the features in release order. It groups them into nine themes (expressiveness, data modeling, control flow, the type system, safety, memory, interop, async, tooling) so you see how they fit together and why they arrived. Then it composes them into eight capstone patterns you’ll recognise from Kestrel, ASP.NET Core and the BCL. Eleven chapters, on .NET 11 and C# 15.

You will learn how to:

•         Read modern C# fluently, from C# 1–4 foundations up to the features that shipped on 10 November 2026

•         Cut ceremony with primary constructors, collection expressions (now with with(...) arguments), raw string literals and the field keyword

•         Model data as values with records, required members and with-expressions, and model closed sets of cases with C# 15 union types

•         Let the compiler prove a switch handles every case, over unions and closed hierarchies alike

•         Use static abstract members and generic math, extension members and extension indexers, and know which ones work on older runtimes

•         Make null a compile-time problem with nullable reference types and the attributes that teach the compiler your try-patterns

•         Write allocation-free code with Span<T>, stackalloc, ref structs and pooled buffers, without falling into the stale-memory trap

•         Call native code with [LibraryImport], and understand what NativeAOT does and doesn’t change about interop

•         Understand async from the state machine up, including .NET 11’s runtime-native async and what it really changes in your stack traces

•         Build async pipelines with channels that fail loudly instead of hanging when a stage breaks

•         Know which features to adopt first in a legacy codebase, with a four-tier priority matrix and an incremental nullable rollout plan

 

Every snippet traces back to one of five runnable companion projects: QuantLite (a trade modeller), DevScripts (a developer toolbox with a real incremental source generator), ChatStream (real-time messaging), TypeForge (a type-system playground) and PerfBench (a BenchmarkDotNet harness). All five build with zero warnings on the .NET 11 SDK, and the samples the book calls production patterns ship with failure-path tests. Each chapter ends with exercises, and all 28 worked solutions are in Appendix C and in their own Visual Studio solution.

Written for developers who have written C# for years and feel the language moved on without them, for developers coming from Java, Go, TypeScript or Rust who want the modern idioms, and for leads deciding which features a team should adopt. The book assumes you can read C# 5. It doesn’t assume you’ve used anything past C# 7. Read the first edition? The Second Edition adds C# 15 and .NET 11 across seven chapters, a new capstone pattern, and corrections to first-edition claims, all listed in the release notes.

Buying for a team? Volume licenses are available from 3 copies, with team pricing up to 40% off for larger groups: one purchase, one invoice, a copy for everyone.

The companion code lives at https://github.com/RachidD68/keeping-up-with-csharp

Share this book

Featured in our articles on

Author

About the Author

Rachid DAHIR

I design systems for the long haul.

As a software architect, technical author, and educator based in Morocco, I've spent more than a decade building enterprise-grade .NET solutions in financial services, healthcare, and large-scale enterprise environments — where reliability, performance, and clean architecture are not optional.

I write for developers who are ready to move past tutorials. My books share a deliberate standard: production-grade code only — no toy examples, no shortcuts that would never survive a code review; every concept explained, demonstrated, then practiced; every advanced topic taught with the same patience as an introductory one — because complexity is never an excuse for a poor explanation.

Whether you're a mid-career developer leveling up, a solution architect consolidating best practices, or an enterprise team standardizing modern .NET, my goal stays the same: clarity without compromise.

When I'm not writing code or prose, I explore mathematics, AI research, and natural health.

Contents

Table of Contents

Front Matter

  • Preface
  • Introduction
  • About the Author

Chapters

  1. The Foundation (C# 1–4)
    • Why revisit the foundation?
    • Generics
    • Nullable value types
    • Iterators and yield return
    • LINQ and its dependencies
    • Everyday conveniences
    • Named and optional parameters
    • Dynamic binding
    • Summary
    • Key Terms
    • Practice Exercises
    • What's Next
  2. Expressiveness & Boilerplate Reduction
    • What this chapter is really about
    • Shrinking the top of the file
    • Strings, reimagined
    • Numeric and default literals
    • Member concision
    • Object construction
    • Collections and variadic arguments
    • The field keyword
    • Summary
    • Key Terms
    • Practice Exercises
    • What's Next
  3. Data Modeling & Functional Techniques
    • Data as values
    • Tuples and discards
    • Records — the crown jewel
    • Init-only properties
    • Required members
    • With-expressions
    • Readonly members on structs
    • Union types (C# 15)
    • Summary
    • Key Terms
    • Practice Exercises
    • What's Next
  4. Evolution of Control Flow (Pattern Matching)
    • Why pattern matching mattered
    • Type patterns
    • Property patterns
    • Switch expressions
    • Relational and logical patterns
    • List patterns
    • Labeled break and continue (C# 15)
    • Summary
    • Key Terms
    • Practice Exercises
    • What's Next
  5. Type System & OOP Flexibility
    • Why the type system kept growing
    • Default interface methods
    • Static abstract members and generic math
    • Generic constraints
    • Ref struct interfaces
    • Closed hierarchies (C# 15)
    • Extension members
    • Small additions that matter
    • Summary
    • Key Terms
    • Practice Exercises
    • What's Next
  6. Safety & Robustness
    • What the compiler started catching for you
    • Nullable reference types
    • The null-conditional family
    • Exception filters
    • CallerArgumentExpression
    • Checked user-defined operators
    • System.Threading.Lock
    • Summary
    • Key Terms
    • Practice Exercises
    • What's Next
  7. Memory & Allocation Control
    • Why allocation became a language feature
    • ref returns, ref locals, ref readonly
    • Span<T> — the core abstraction
    • ref struct and the rules around them
    • stackalloc in safe contexts
    • Memory<T> for async-compatible buffers
    • ArrayPool<T> and MemoryPool<T>
    • Ranges and indices
    • UTF-8 string literals
    • allows ref struct and the C# 14 papercut fixes
    • Summary
    • Key Terms
    • Practice Exercises
    • What's Next
  8. Low-Level & Interop Primitives
    • The last layer between managed and native
    • Native integers — nint and nuint
    • Function pointers — delegate*
    • Unmanaged constructed types
    • [StructLayout] for binary protocols
    • [LibraryImport] — modern P/Invoke
    • A first look at C# 15's memory-safety preview
    • Summary
    • Key Terms
    • Practice Exercises
    • What's Next
  9. Asynchronous Programming Evolution
    • Why async is hard and why C# fixed it
    • async/await foundation
    • The async state machine
    • Runtime-native async (.NET 11)
    • ValueTask<T> and when to use it
    • Async streams — IAsyncEnumerable<T>
    • IAsyncDisposable
    • ConfigureAwait and SynchronizationContext
    • Cancellation patterns
    • Task combinators
    • Summary
    • Key Terms
    • Practice Exercises
    • What's Next
  10. Compiler & Tooling Integration
    • The meta-layer
    • Caller info attributes
    • Module initializers
    • Source generators
    • Interceptors
    • Partial members: properties, constructors, events
    • Summary
    • Key Terms
    • Practice Exercises
    • What's Next
  11. Modern C# in Practice — Capstone (8 Patterns)
    • Why these patterns
    • Pattern 1: Immutable Data
    • Pattern 2: Null-Safe API
    • Pattern 3: Zero-Allocation
    • Pattern 4: Scripting
    • Pattern 5: Source Generator
    • Pattern 6: Generic Math
    • Pattern 7: Async Pipeline
    • Pattern 8: Exhaustive Domain Modeling
    • Closing — what you've built up
    • Summary
    • Key Terms
    • Practice Exercises (final)
    • The end

Appendices

  • Appendix A — Migration & Adoption Guide
  • Appendix B — Feature Quick-Reference Index
  • Appendix C — Exercise Solutions
  • Keyword Index

Get the free sample chapters

Click the buttons to get the free sample in PDF or EPUB, or read the sample online here

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub