using directive
A line such as using System.Text; that lets a file refer to types in a namespace by their short names.
In more detail
Marking it global using applies it to every file in the project, and many projects keep those in one GlobalUsings.cs file. Do not confuse it with a using declaration, which disposes an object.
Example
global using Catalog.Contracts;Related terms
- namespace — A name prefix that groups related names under one owner, so the same short name from different owners does not collide.
- implicit usings — A project setting that makes the SDK add common using directives, such as System and System.Linq, to every file automatically.
- using declaration — A local variable declared with using, as in using var stream = File.OpenRead(path);, whose Dispose method runs automatically at the end of the enclosing scope.
Taught in
- What is .NET? Runtime vs SDK, and LTS vs STS — Modern .NET Core, C# & Enterprise Microservices
- Records, Pattern Matching, and Modern C# — Modern .NET Core, C# & Enterprise Microservices