Reputation: 1524
I have two namespaces:
System.Numerics and UnityEngine
Both have the type Vector3
.
So now when ever i want to use it i have to declare which namespace before it. Like this:
protected struct CVN
{
public Complex h;
public UnityEngine.Vector2 d;
public UnityEngine.Vector3 n;
}
Is there any way to define that i only want Vector3
from one namespace so i don't have to always type NameSpaceHere.Vector3
every single time ?
Or am i stuck with the tedious nature of stating the namespace every time. Especially since i only need the Complex
type from Numerics its quite annoying.
Upvotes: 2
Views: 565
Reputation: 1040
You can wrap the using directive of the wanted class in the namespace of your current class rather than putting it outside. Consider this example
namespace System.Numerics
{
class MyClass
{
}
}
namespace UnityEngine
{
class MyClass
{
}
}
using System.Numeric;
namespace ConsoleApplication24
{
using UnityEngine; // inside the namespace
class Program
{
static void Main(string[] args)
{
MyClass xx = new MyClass(); // from UnitEngine instead of System.Numeric
}
}
}
Upvotes: 2
Reputation: 4515
If all you need from System.Numerics
is Complex
, then:
using UnityEngine;
using Complex = System.Numerics.Complex;
At the top of your file, without using System.Numerics;
should do it.
This is an alias.
Upvotes: 6