Oops, I thought this had been published a long time ago, but oh well: it is never too late to publish reflections on a C# programming language improvement.
After recovering from my rectum cancer treatments and finally upgrading most of my projects to recent enough C# versions, it was time to catch up on useful little C# language features released during my treatments.
This one is really nice: [Wayback/Archive] File scoped namespaces – C# 10.0 draft specifications | Microsoft Learn.
I wish it had been released much earlier, as it so much reminds me of the unit keyword in Delphi which influenced C# a lot. Well, actually the unit actually started in UCSD Pascal and Turbo Pascal; UCSD Pascal ran on the UCSD p-Machine (more on that in a future blog post), which influenced the Java Virtual Machine, which was based on Java bytecode and a Just-in-time compiler in turn influenced the .NET Common Language Runtime.
There are many examples from other languages, paradigms and frameworks: I love how C# and .NET bring so much programming history together.
In Delphi it is easy: a source file can contain at maximum one unit (and apart from files included in that source file, no other source files can contribute to that unit) and the filename needs to match the unitname, so the unit is a self contained namespace.





