How I can “save” my “not used” directive using from removing? (Visual Studio 2022)
[screenshot]
I can place using between #if !DEBUG
and #endif
, but I hope to find something global.
Is there something I can change in the Visual Studio settings?
Thanks.
Edit: More solutions:
Write global using System.Collections.Generic;
Use full qualified within the #if
6
Here are examples of how to avoid adding extra using statements:
Example 1: Using Global Usings
// In GlobalUsings.cs
global using System.Diagnostics;
This is best for commonly-used namespaces across multiple files.
Example 2: Using Fully Qualified Names in #if
#if DEBUG
System.Diagnostics.Debug.WriteLine("Debug mode");
#endif
This is best for rarely-used namespaces.
1