Simplification of the using directives
A top-level statement is a new feature introduced in C# 9.0, which makes it easy for developers to remove the ceremony code. The project templates that come with Visual Studio 2022 embrace the language changes introduced in C# such as top-level statements. For example, if you create a Console application, you will see the Program.cs file contains the code shown in the following snippet:
// See https://aka.ms/new-console-template for more //information
Console.WriteLine("Hello, World!");
The preceding code came with a console application template that did not have the ceremony code such as class definition and the main method. This simplified the number of lines we could write by removing the redundant code.
The concepts of the implicit using directives and global using directives introduced in C# 10 reduce the repetition of the using statements in each CS file.
The global using directives
With the global using directives...