Top-Level Statements

noun

say it: “TOP LEV-ul STAYT-ments” /tɒp ˈlɛvəl ˈsteɪtmənts/

Writing a C# program's code straight in the file, without a Program class or a Main method around it.

What is Top-Level Statements in C#?

Top-Level Statements — A feature that allows a small C# program to omit an explicit Program class and Main method.

class Program
{
    static void Main()
    {
        string message = "Hello, C#!";
    }
}

In a sentence

  • “Thanks to top-level statements, my first program was one line: Console.WriteLine("Hi");.”

Level: Novice · More C# terms at this level

Updated