Skip to content

C# Feature โ€“ File-scoped namespaces

Use a semicolon after namespace to scope the entire file, avoiding an extra block and indentation.

C# 10 (2021)

namespace MyApp
{
class C {}
}
namespace MyApp;
class C {}
  • One file-scoped namespace per file.