Practice mode C#

What does a file-scoped namespace declaration such as namespace MyApp.Models; do in C# 10 and later?

Correct answer C. It places every type in the file into that namespace without an extra pair of braces

Explanation

A file-scoped namespace applies to the whole file, so you avoid one level of braces and indentation. Types declared after it belong to MyApp.Models exactly as with a block-scoped namespace and are visible elsewhere. Importing a namespace is done with a using directive. A file can contain only one file-scoped namespace declaration.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.