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

🧐 How to keep Account lean in Dataverse?

🧐 How to keep Account lean in Dataverse? Inheritance is not so useful in the OOP realm! 💥Bold statement, but why? Inheritance has a rigid structure, a strict hierarchy that proves difficult to change. Often you need to adjust the full or part of the inheritance...

read more

Four stages to automation:

Four stages to automation: 🗑️ The Reclaim Stage Dispose of the activities yielding minimal outcomes. You may need to remove unnecessary apps from your phone or reluctantly say goodbye to less fruitful clients. 📑 The Document Stage Create a written Standard Operating...

read more
Share This