top-level statements

C# code written directly at the top of Program.cs, without a class or Main method, from which the compiler generates the program's entry point.

In more detail

Only one file in a project may use them, and they must come before any type declarations in that file. They are ordinary compiled C#, not a scripting mode: you can declare variables, call methods and use await.

Related terms

Taught in

References