Home > front end >  In Visual Studio is there a way to define a using statement for the whole project? ex. using Random
In Visual Studio is there a way to define a using statement for the whole project? ex. using Random

Time:01-19

I consistently am dealing with ambiguous references between System.Random and UnityEnginge.Random. To address this I need to add the "using Random = UnityEngine.Random;" to each file. I was curious if instead I could somehow set Random to always use the UnityEngine namespace for the whole project by default.

Manually changing every file seems to be the only solution I could find.

CodePudding user response:

You can use global using statements. The global using directive is a new feature that was recently added to C# language in C# version 10.0. This feature allows to declare a namespace globally in any one of the files in a project and the global declared namespace is imported and available to all files in the application

EX:

global using System.IO;

CodePudding user response:

Yes a recent addtion to C# was the global using statementP. ut into a .cs file in root of project with code like this:

global using MyAssert = Nunit.Assert;
  • Related