Top Level Statements Flashcards
What are top-level statements?
Statements that are not part of a class method or namespace.
Starting from what version of C# is using top-level statements allowed?
C# 9.
How many files with top-level statements can exist in a C# program?
One.
In a file with top-level statements, can you include using directives?
Yes, but they must be placed before the top-level statements.
Can a file with top-level statements contain namespaces and types?
Yes, but they must come after the top-level statements.
How can you access the arguments of an executable in a file with top-level statements?
Using the pre-declared args variable.
Can you use await in a file with top-level statements?
Yes.
Can you return an int in the top-level statements?
Yes.