2021 Advent of Code
It’s almost December, and that means a new Advent of Code begins. I am freezing and its late so this is a quick one.
I maintain a Github template that I update yearly to reflect the latest C#/.NET features available.
The biggest changes to the template this year is the addition of global usings and file scoped namespace declarations.
This isn’t going to affect performance, but it will let me delete a bunch of (now) unnecessary code.
For example:
Can now simply be:
We reduced the file size a bit, cleaned up one level of (now) redundant indentation and got the easiest win of the “learning the latest C# features” endeavor.
However, those using directives still need to go somewhere…
Since the 3 using directives I removed are all needed across the board in this project, I added them to the Program.cs file, along with the new global
modifier. (Note This was a logical central point to me, its not required to go specifically here; the modifier can be used anywhere!)
The way I have structured this project means I have one folder for every day in the Advent of Code calendar. Removing n
of using directives, across 25 folders gave me a lot of pre-holiday joy.
The C# language team have been making wonder & welcome additions to the language yearly. This isn’t Steve Ballmer’s Microsoft anymore…
Happy holidays!