What’s new in C# 10
Mar 24, 2022
File-scoped namespace declaration
It seems little, but it has been a useful touch for reusability.
As with many of the recent changes in C# 9 and the upcoming C# 10, this change is designed to reduce “noise” in our code and make C# more readable. If you have written C#, you will recognize the format for defining the namespace our code is in:
namespace X.Y.Z
{
//more code
}
We need those curly braces around all of our classes before we have anything else written; we have at least 4 lines of code already. With file scoped namespaces, we can have the namespace defined without the need for the scoped braces:
namespace X.Y.Z;
//more code
Enjoy Coding…