Introduced in C# 9.0, top-level statements remove unnecessary ceremonial code from the program.
To write a simple hello world program, a C# program is written like this:
using System; namespace HelloWorld { class Program { static void Main(string[] args) { Console.WriteLine("Hello World!"); } } }
The program needs to include multiple lines of code in order to print a single statement.
With top-level statements, the code can be reduced to simply:
using System; Console.WriteLine("Hello World!");
Hello World!
Main()
method or program entry point methods.RELATED TAGS
CONTRIBUTOR
View all Courses