Introducing C# 9: Attributes on local functions

by anthonygiretti, 2020-10-19T01:01:24.728Z

Well. It has been a while since I wanted to write this post but I couldn’t find any relevant code example to illustrate it. As you might have guessed C# 9 now allows attributes on local functions (as well as parameter attributes of local functions). To illustrate this I will show you how to use the Conditional attribute to perform conditional local function executions, for example, depending on the environment in which we are running our program. Applying it to local functions can be interesting in this case, however I admit that for the moment it is the only relevant example but it does not matter it is not necessarily the functionality of C# 9 either. more popular now. Finally we will compare with the C# 9 forward to finish our example.

Read More