Dissecting local functions in C#.

by Nov 7, 2023

Dissecting local functions in C#.

At first glance, seemed like a complication, an ugly addition to the clean and elegant C# landscape! I didn’t get it.

Then, boom – I fell for these misfits.

I began to understand their charm.

Inserting the lower-level details into separate methods to make the intent of the code clear – that’s how it usually works, right? It’s a good strategy, but can lead to a clutter of tiny methods making the code difficult to decipher. Here lies the gray area, a fine balance to master.

Ever had code too specific and small for a separate method, yet you had to isolate it?

Enter local functions, your savior!

They simplify your code and transport the specifics into a function nestled at the end of your method. Out of sight, but not out of mind – just under the rug.

Do you find this compelling? Share your experiences with local functions in C#.


Subscribe to
The Daily Friction

A daily newsletter on automation and eliminating friction

Related Content

Standup meetings

Standup meetings Why have a Teams channel where everyone can post what they are struggling with, so anyone can respond to help and start a 1-on-1 call. If we can have 15-min meetings informing everyone once a day.

read more

Complexity <> Sophisticated

Complexity <> Sophisticated It can be just overly complex, because the person who created it didn't understand it well enough. Teachers face the challenge of breaking down complex subjects for their students. The ability to simplify abstract ideas without losing...

read more
Share This