Steven Giesel

C# Lowering - What is it and why should I care?

The C# compiler turns one `yield` keyword into an entire state machine. Learn how this hidden process impacts your code's performance and memory usage.

C# Lowering - What is it and why should I care?
#1about 7 minutes

Defining C# lowering and its benefits

C# lowering is the process of transforming high-level language features into simpler constructs, which simplifies the compiler and ensures predictable performance.

#2about 3 minutes

Subtle differences in property getter implementations

The `var` keyword is lowered to its inferred type, while expression-bodied properties can introduce subtle behavioral changes compared to traditional getters.

#3about 4 minutes

How `foreach` is lowered for arrays versus lists

A `foreach` loop is lowered to an index-based `while` loop for arrays but uses the `IEnumerable` pattern with a `try-finally` block for lists, impacting performance.

#4about 2 minutes

The danger of using `async` without `await` in `using` blocks

Combining `IDisposable` with an `async` call without `await` can lead to the object being disposed before the asynchronous operation completes.

#5about 9 minutes

Understanding the `yield` keyword and its performance

The `yield` keyword generates a state machine class to enable deferred execution, trading slower per-item runtime for significantly lower memory allocation.

Related jobs
Jobs that call for the skills explored in this talk.

Featured Partners

Related Articles

View all articles
BR
Benjamin Ruschin
What Developers Really Need to Create Great Code Demos
Every developer on earth has, at some point, had another developer to thank for a breakthrough, a success, an aha moment they wouldn’t have had without coming across that blog post, that open-source contribution, that reply on socials or that humble ...
What Developers Really Need to Create Great Code Demos
CH
Chris Heilmann
All the videos of Halfstack London 2024!
Last month was Halfstack London, a conference about the web, JavaScript and half a dozen other things. We were there to deliver a talk, but also to record all the sessions and we're happy to share them with you. It took a bit as we had to wait for th...
All the videos of Halfstack London 2024!
DC
Daniel Cranney
Dev Digest 193: Vibe Coding Honeymoon, NaN and the End of Interviews
Inside last week’s Dev Digest 193 . 🛰️ A satellite of doom 🤔 Why em-dashes? 😔 Vibe coding Honeymoon is over 🖼️ GenAI image showdown 🔥 Dangers of firewalls and VPNs 👨‍💼 AI broke interviews 🦉 A LinkedIn wisdom generator 🗞️ Join over 150,000 developers...
Dev Digest 193: Vibe Coding Honeymoon, NaN and the End of Interviews

From learning to earning

Jobs that call for the skills explored in this talk.

C# Developer

C# Developer

Understanding Recruitment
Charing Cross, United Kingdom

£120K
Intermediate
Python
Kubernetes
Amazon Web Services (AWS)
Software Engineer C#

Software Engineer C#

SAFELOG GmbH
Markt Schwaben, Germany

Remote
Intermediate
GIT
Microsoft SQL Server