liveBook · Manning

Global using directive

A global using directive is a C# import whose namespace or type availability applies throughout all source files in a compilation.

How 2 Manning books explain it

.NET MAUI in Action

A global using statement imports a namespace for every source file in a C# project.

How it is used
Reduces boilerplate namespace references across repeatedly used files in a .NET MAUI project.
How deep it goes
Defines project-wide availability, then gives a setup procedure, but does not explore compiler or resolution internals.
Examples
Uses GlobalUsings.cs and the MauiStockTake.UI.Pages namespace as the concrete setup example.
What you can do after
Apply it via a GlobalUsings.cs file to share repeatedly used namespaces across project files.

Read how .NET MAUI in Action explains global using directive →

.NET in Action, Second Edition

A global using directive makes a namespace or type import available throughout all files in a C# compilation unit.

How it is used
Reduces repeated namespace imports across console applications and other projects.
How deep it goes
Explains source-file and project-file declarations, but does not descend into compiler implementation.
Examples
Uses System, Figgle, GlobalUsings.cs, and project-file Using entries as concrete examples.
What you can do after
Apply it via C# declarations or .csproj entries to shorten source files.

Read how .NET in Action, Second Edition explains global using directive →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.