advertise with us

Use file-level namespaces in C# 10 to reduce vertical nesting

In C# 9 we saw how top-level statements can help us reduce ‘wasted’ vertical space…

BUT… reducing ‘wasted’ horizontal space and in particular nesting levels is much more valuable IMHO and in C# 10 (released November 2021) we have file-level namespaces to help with this.

File-level namespaces are definitely one of my favourite features from C# 10 and Milan Jovanović’s example (originally posted on LinkedIn) below shows what they look like…

Another approach to reducing nesting levels is to use guard clauses.


Need Help with Your C# Projects?

We offer expert support and development services for projects of any size. Contact us for a free consultation and see how we can help you succeed.

CONTACT US NOW